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 12f523c..306232f 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 @@ -202,7 +202,7 @@ Transform: m_LocalScale: {x: 2.585, y: 1, z: 1.2} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0} --- !u!1 &299496350 GameObject: @@ -294,7 +294,7 @@ Transform: m_LocalScale: {x: 2.585, y: 1, z: 1.2} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &503604495 GameObject: @@ -407,7 +407,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4472652550524646, guid: 1f68bf7cec2600e49a46d2f0554453c8, type: 3} propertyPath: m_RootOrder - value: 8 + value: 7 objectReference: {fileID: 0} - target: {fileID: 4472652550524646, guid: 1f68bf7cec2600e49a46d2f0554453c8, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -545,7 +545,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -619,7 +619,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} --- !u!1 &797223803 GameObject: @@ -785,7 +785,7 @@ RectTransform: - {fileID: 797223804} - {fileID: 1959362813} m_Father: {fileID: 0} - m_RootOrder: 7 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -821,7 +821,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 0 + m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &914806966 MonoBehaviour: @@ -835,8 +835,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: e7eda42473bde25468ccb55d2b565cf9, type: 3} m_Name: m_EditorClassIdentifier: - img: {fileID: 2142686115215515793, guid: 8bbc036a3be21954681613cbe4f0e9a8, type: 3} + img: {fileID: 2829506254029656376, guid: 8bbc036a3be21954681613cbe4f0e9a8, type: 3} canvas: {fileID: 798465533} + frame_gap: 20 + delta_threshold: 100 + img_fade_speed: 0.02 + img_wait_sec: 2 --- !u!1 &963194225 GameObject: m_ObjectHideFlags: 0 @@ -918,7 +922,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 1 + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &963194229 MonoBehaviour: @@ -1005,7 +1009,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 6 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} 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 21cbba0..66619e8 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 @@ -9,18 +9,18 @@ public class movieController : MonoBehaviour { DShowMoviePlayer player; public int id; - public float fade_speed = 0.02f; public int stat; - public float alpha; + public float fade_speed; + public bool force_destroy; public float destroy_timer; - public bool CanDsetroy; - float wait_sec = 2f; + public float wait_sec = 2f; + float alpha; void Awake() { player = GetComponent(); - CanDsetroy = true; stat = 1; + force_destroy = false; } void Start() @@ -45,6 +45,10 @@ public class movieController : MonoBehaviour } } + else if (stat == 2 && force_destroy) + { + stat = 3; + } else if (stat == 3) { float t = Time.time; @@ -52,7 +56,7 @@ public class movieController : MonoBehaviour { //Debug.Log("fade"); alpha -= fade_speed; - if (alpha < 0 && CanDsetroy) + if (alpha < 0) { Destroy(this.gameObject); } 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 326208d..42b7da0 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 @@ -1,16 +1,31 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using UltraCombos.Configuration; public class tuio_event : MonoBehaviour { -#if true - public GameObject img; + public movieController img; public Transform canvas; - //public UltraCombos.GlobalMKHookInput tuio_input; Dictionary movies = new Dictionary(); Dictionary pre_pos = new Dictionary(); + [Config] + [Range(1, 30)] + public int frame_gap = 20; + + [Config] + [Range(50, 300)] + public int delta_threshold = 100; + + [Config] + [Range(0.01f, 0.1f)] + public float img_fade_speed = 0.02f; + + [Config] + [Range(0.01f, 5f)] + public float img_wait_sec = 2f; + void Update() { var touches = TUIOManager.Instance.touches; @@ -19,49 +34,33 @@ public class tuio_event : MonoBehaviour movieController movie = null; if (movies.ContainsKey(id) == false) // Add { - Debug.Log("Add"); - GameObject g = Instantiate(img, canvas); + //Debug.Log("Add"); + GameObject g = Instantiate(img.gameObject, canvas); g.name = id.ToString(); movie = g.AddComponent(); + movie.fade_speed = img_fade_speed; + movie.wait_sec = img_wait_sec; movie.id = id; movies.Add(id, movie); movie.transform.position = touches[id].position; - pre_pos.Add(id, touches[id].position); + pre_pos[id] = touches[id].position; } else //update { - if (Time.frameCount % 10 == 0) + movie = movies[id]; + if (Time.frameCount % frame_gap == 0) { - float delta_pos = Vector2.Distance(pre_pos[id], touches[id].position); - if (delta_pos > 200) + float delta_pos = Vector2.Distance(pre_pos[id], movie.transform.position); + //float delta_pos = 199; + //Debug.Log("delta pos = " + delta_pos); + if (delta_pos > delta_threshold) { - Debug.Log("generate new one"); - GameObject g = Instantiate(img, canvas); - int clone_id = id + Random.Range(5000, 10000); - g.name = clone_id.ToString(); - movie = g.AddComponent(); - movie.id = clone_id; - movies.Add(clone_id, movie); - movie.transform.position = pre_pos[id]; - movie.transform.localRotation = movies[id].transform.localRotation; - movie.alpha = 0.9f; - - movies[id].stat = 0; - movies[id].transform.position = touches[id].position; - movies[id].CanDsetroy = false; - movies[id].rotateImg(); - - pre_pos[id] = touches[id].position; - } - else - { - //movies[id].transform.position = touches[id].position; + movie.force_destroy = true; + movie.destroy_timer = Time.time; + movies.Remove(id); } + pre_pos[id] = touches[id].position; } - else - { - movie = movies[id]; - } } //update or after adding //Debug.Log("Update"); @@ -83,12 +82,10 @@ public class tuio_event : MonoBehaviour { movies[id].stat = 3; movies[id].destroy_timer = Time.time; - movies[id].CanDsetroy = true; movies.Remove(id); - Debug.Log("Remove"); + //Debug.Log("Remove"); } //movies[id].destroy_timer = Time.time; } } -#endif } diff --git a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Packages/manifest.json b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Packages/manifest.json index 2590a96..6ea371b 100644 --- a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Packages/manifest.json +++ b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Packages/manifest.json @@ -3,6 +3,8 @@ "com.ultracombos.movie-player": "file:/../../../../../_Package/com.ultracombos.movie-player", "com.ultracombos.tuio": "file:/../../../../../_Package/com.ultracombos.tuio", "com.ultracombos.osc": "file:/../../../../../_Package/com.ultracombos.osc", + "com.ultracombos.grpc": "file:/../../../../../_Package/com.ultracombos.grpc", + "com.ultracombos.configuration": "file:/../../../../../_Package/com.ultracombos.configuration", "jp.keijiro.klak.spout": "file:/../../../../../_Package/KlakSpout", "com.unity.ads": "2.0.8", "com.unity.analytics": "3.2.2",