From f2bd9dffe0ef1f15970c0afa553aed68fb82a50c Mon Sep 17 00:00:00 2001 From: tigerchen Date: Thu, 19 Dec 2019 15:04:40 +0800 Subject: [PATCH 1/4] separate audio from video & snow size config --- .../Assets/Scenes/DarkSea.unity | 101 +++++++++++++++++- .../Assets/Scripts/StatManager.cs | 41 +++++-- .../Assets/Scripts/movieController.cs | 3 + .../Assets/Scripts/tuio_event.cs | 5 + 4 files changed, 139 insertions(+), 11 deletions(-) diff --git a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scenes/DarkSea.unity b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scenes/DarkSea.unity index 7f533bf..e7eabce 100644 --- a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scenes/DarkSea.unity +++ b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scenes/DarkSea.unity @@ -308,6 +308,7 @@ GameObject: m_Component: - component: {fileID: 388490436} - component: {fileID: 388490435} + - component: {fileID: 388490437} m_Layer: 0 m_Name: StatManager m_TagString: Untagged @@ -328,11 +329,12 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: fade_sec: 1 - loop_to_trigger: 4 + loop_to_trigger: 1 idle_player: {fileID: 540220394} h_player: {fileID: 1232323602} h_grp: {fileID: 229700563} s_grp: {fileID: 1191269363} + horse_clip: {fileID: 8300000, guid: 10adc664ed6fa7641bc9be8e020216cf, type: 3} --- !u!4 &388490436 Transform: m_ObjectHideFlags: 0 @@ -347,6 +349,102 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!82 &388490437 +AudioSource: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 388490434} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 0} + m_audioClip: {fileID: 8300000, guid: 1320bfe591757af4ca58ba59f1dda347, type: 3} + m_PlayOnAwake: 1 + m_Volume: 1 + m_Pitch: 1 + Loop: 1 + Mute: 0 + Spatialize: 0 + SpatializePostEffects: 0 + Priority: 128 + DopplerLevel: 1 + MinDistance: 1 + MaxDistance: 500 + Pan2D: 0 + rolloffMode: 0 + BypassEffects: 0 + BypassListenerEffects: 0 + BypassReverbZones: 0 + rolloffCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + panLevelCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + spreadCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + reverbZoneMixCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 --- !u!1001 &472923654 PrefabInstance: m_ObjectHideFlags: 0 @@ -770,6 +868,7 @@ MonoBehaviour: VisualizeTouches: 1 frame_gap: 10 delta_threshold: 100 + snow_size: 256 img_fade_speed: 0.02 img_wait_sec: 2 audio_volume: 1 diff --git a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/StatManager.cs b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/StatManager.cs index e88e885..71ccae6 100644 --- a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/StatManager.cs +++ b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/StatManager.cs @@ -20,10 +20,16 @@ public class StatManager : MonoBehaviour public DShowMoviePlayer h_player; public CanvasGroup h_grp; public CanvasGroup s_grp; - + public AudioClip horse_clip; + + AudioSource aud; int loop_count; float h_lerp_val; float s_lerp_val; + float h_total_time = 30f; + float i_total_time = 8f; + float trigger_time; + float m_timer; void Start() { @@ -31,18 +37,32 @@ public class StatManager : MonoBehaviour loop_count = 0; h_lerp_val = 0f; s_lerp_val = 1f; + m_timer = h_total_time; } void Update() { - if(h_player.IsPlaying == false){ - if (idle_player.Frame == idle_player.TotalNumFrames) - { - loop_count += 1; + trigger_time = i_total_time * loop_to_trigger + h_total_time; + m_timer += Time.deltaTime; + Debug.Log(m_timer); + + //if(h_player.IsPlaying == false){ + if (true) + { + //if (idle_player.Frame == idle_player.TotalNumFrames) + //{ + // loop_count += 1; //Debug.Log(loop_count); - } - if (loop_count >= loop_to_trigger) + //} + //if (loop_count >= loop_to_trigger) + if (m_timer > trigger_time) { + aud = gameObject.AddComponent(); + aud.loop = false; + aud.playOnAwake = false; + aud.clip = horse_clip; + aud.Play(); + m_timer = 0f; Debug.Log("horse fade in"); h_player.Play(); StartCoroutine("h_fade_in"); @@ -50,7 +70,7 @@ public class StatManager : MonoBehaviour } } - else + if (h_player.IsPlaying) { if(h_player.GetCurrentTime == 18f) { @@ -64,9 +84,9 @@ public class StatManager : MonoBehaviour StartCoroutine("s_fade_in"); } - if(h_player.Frame == h_player.TotalNumFrames - fade_sec * 30) + if(h_player.GetCurrentTime > h_total_time - fade_sec) { - idle_player.Frame = 0; + //idle_player.Frame = 0; Debug.Log("horse fade out"); StartCoroutine("h_fade_out"); } @@ -94,6 +114,7 @@ public class StatManager : MonoBehaviour h_grp.alpha = Mathf.Lerp(0f, 1f, h_lerp_val); yield return null; } + Destroy(aud); yield break; } diff --git a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/movieController.cs b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/movieController.cs index 7624514..64b5113 100644 --- a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/movieController.cs +++ b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/movieController.cs @@ -16,6 +16,7 @@ public class movieController : MonoBehaviour public float destroy_timer; public float wait_sec = 2f; public float volume = 1f; + public Vector2 size; public DShowClip snow_01; public DShowClip snow_02; public DShowClip snow_03; @@ -46,6 +47,8 @@ public class movieController : MonoBehaviour void Update() { aud.volume = volume; + GetComponent().sizeDelta = size; + if (playAud && aud.clip != null) { Debug.Log(aud.clip.name); diff --git a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/tuio_event.cs b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/tuio_event.cs index de0b7c1..10ea719 100644 --- a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/tuio_event.cs +++ b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/tuio_event.cs @@ -22,6 +22,10 @@ public class tuio_event : MonoBehaviour [Range(50, 300)] public int delta_threshold = 100; + [Config] + [Range(128, 512)] + public int snow_size = 256; + [Config] [Range(0.01f, 0.1f)] public float img_fade_speed = 0.02f; @@ -51,6 +55,7 @@ public class tuio_event : MonoBehaviour movie = g.AddComponent(); movie.fade_speed = img_fade_speed; movie.wait_sec = img_wait_sec; + movie.size = new Vector2(snow_size, snow_size); movie.volume = audio_volume; movie.id = id; movies.Add(id, movie); From 6b8bfcad3681036dce5f07feddee666c9351ced5 Mon Sep 17 00:00:00 2001 From: tigerchen Date: Thu, 19 Dec 2019 20:12:49 +0800 Subject: [PATCH 2/4] add debug config --- .../Assets/Scenes/Ice.unity | 4 +- .../Assets/Scripts/DebugUI.cs | 43 +++++++++++-------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/01_ForstCoronation/Unity-19050-01_ForstCoronation/19050-01_ForstCoronation/Assets/Scenes/Ice.unity b/01_ForstCoronation/Unity-19050-01_ForstCoronation/19050-01_ForstCoronation/Assets/Scenes/Ice.unity index aeb549a..f0706d9 100644 --- a/01_ForstCoronation/Unity-19050-01_ForstCoronation/19050-01_ForstCoronation/Assets/Scenes/Ice.unity +++ b/01_ForstCoronation/Unity-19050-01_ForstCoronation/19050-01_ForstCoronation/Assets/Scenes/Ice.unity @@ -1341,8 +1341,8 @@ MonoBehaviour: m_ExecuteInEditor: 1 m_Bindings: - {fileID: 1090188929} - - {fileID: 1090188931} - {fileID: 1090188930} + - {fileID: 1090188931} m_VisualEffect: {fileID: 1090188927} --- !u!114 &1090188933 MonoBehaviour: @@ -1810,7 +1810,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 3d9a54ec27de1e74484ba710356b1a50, type: 3} m_Name: m_EditorClassIdentifier: - debugMode: 1 canvas: {fileID: 396373727} vfx: {fileID: 1090188927} baseEmitter: {fileID: 706372899} @@ -1818,6 +1817,7 @@ MonoBehaviour: emitter: {fileID: 1324214445} button: {fileID: 562864505} stat: + debugMode: 0 Emitter_x: 3.5 Target_x: -3 growing_speed: 0.008 diff --git a/01_ForstCoronation/Unity-19050-01_ForstCoronation/19050-01_ForstCoronation/Assets/Scripts/DebugUI.cs b/01_ForstCoronation/Unity-19050-01_ForstCoronation/19050-01_ForstCoronation/Assets/Scripts/DebugUI.cs index 08469d1..fd89eb1 100644 --- a/01_ForstCoronation/Unity-19050-01_ForstCoronation/19050-01_ForstCoronation/Assets/Scripts/DebugUI.cs +++ b/01_ForstCoronation/Unity-19050-01_ForstCoronation/19050-01_ForstCoronation/Assets/Scripts/DebugUI.cs @@ -8,7 +8,7 @@ using TUIO; public class DebugUI : MonoBehaviour { - public bool debugMode = true; + public GameObject canvas; public VisualEffect vfx; public GameObject baseEmitter; @@ -17,6 +17,9 @@ public class DebugUI : MonoBehaviour public GameObject button; public string stat = "wait"; + [Config] + public bool debugMode = false; + [Config] [Range(0f, 5f)] public float Emitter_x = 2.5f; @@ -42,15 +45,31 @@ public class DebugUI : MonoBehaviour { QualitySettings.vSyncCount = 0; stat = "wait"; - canvas.SetActive(debugMode); + //canvas.GetComponent().ena(debugMode); button.GetComponent().text = stat; lerp_val = 0; cur_blob_count = 0; + setObjectVisible(debugMode); } // Update is called once per frame void Update() { + if (Input.GetKeyDown(KeyCode.F1)) + { + debugMode = !debugMode; + //canvas.GetComponent().enabled = debugMode; + if (debugMode) + { + showObject = true; + setObjectVisible(showObject); + } + else + { + showObject = false; + setObjectVisible(showObject); + } + } cur_blob_count = TUIOManager.Instance.touches.Count; if (button.GetComponentInParent