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 333ec4e..2bf869b 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 @@ -418,6 +418,11 @@ PrefabInstance: propertyPath: tuio_event value: objectReference: {fileID: 914806966} + - target: {fileID: 2829506254029656376, guid: 8bbc036a3be21954681613cbe4f0e9a8, + type: 3} + propertyPath: fade_speed + value: 0.02 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 8bbc036a3be21954681613cbe4f0e9a8, type: 3} --- !u!224 &490275148 stripped 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 7acdfb2..29c069c 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 @@ -8,70 +8,66 @@ public class movieController : MonoBehaviour public float totalTime = 0.5f; public int id; public tuio_event tuio_event; - int stat; + public float fade_speed = 0.02f; + public int stat; Vector2 final_size; + float c; + Vector2 pos, pre_pos; //public Transform trans; // Start is called before the first frame update void Start() { - final_size = GetComponent().sizeDelta = Vector2.zero; - GetComponent().sizeDelta = Vector2.zero; - stat = 0; + final_size = GetComponent().sizeDelta; + GetComponent().color = Color.clear; + pos = Vector2.zero; } // Update is called once per frame void Update() { - if(name == "RawImage") + //Debug.Log(stat); + pre_pos = pos; + + if (name == "RawImage") { GetComponent().enabled = false; } else { GetComponent().enabled = true; - //Debug.Log(stat); } if (tuio_event.tuio_input.touchCount > 0) { transform.gameObject.SetActive(true); - Vector2 pos = tuio_event.tuio_input.GetTouch(id).position; + if (stat == 1) + pos = tuio_event.tuio_input.GetTouch(id).position; + else if (stat == 2) + pos = pre_pos; GetComponent().position = new Vector3(pos.x, pos.y, 0); - } - } - - void wake() - { - - } - - void die() - { - Destroy(this); - } - - void doScaling(float to) - { - float from = transform.localScale.x; - float scale = from; - float startTime = Time.time; - while (scale != to) + } + if(stat == 1) + { + c += fade_speed; + } + else if (stat == 2) { - float duration = Time.time - startTime; - scale = Mathf.Lerp(from, to, duration / totalTime); - transform.localScale = new Vector3(scale, scale, 1); + c -= fade_speed; + if (c < 0f) Destroy(gameObject); } + c = Mathf.Clamp(c, 0f, 1f); + GetComponent().color = new Color(1f, 1f, 1f, c); } private void OnEnable() { - //doScaling(1); + stat = 1; + c = 0f; Debug.Log("Hi"); } private void OnDestroy() { - //doScaling(0); Debug.Log("Bye"); } } 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 3f3fc06..cc25c43 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 @@ -23,10 +23,6 @@ public class tuio_event : MonoBehaviour // Update is called once per frame void Update() { - if (Input.GetKeyDown(KeyCode.K)) - { - Destroy(GameObject.Find("eee")); - } pre_count = cur_count; pre_ids.Clear(); cur_ids.ForEach(i => pre_ids.Add(i)); @@ -54,17 +50,17 @@ public class tuio_event : MonoBehaviour } } } - else if (cur_count < pre_count) // Remove { //Debug.Log("Remove"); for (int i = 0; i < pre_count; i++) { int _id = pre_ids[i]; - bool isExitTouch = cur_ids.Contains(_id); - if (isExitTouch == false) + bool isExitTouch = !cur_ids.Contains(_id); + if (isExitTouch) { - Destroy(GameObject.Find(_id.ToString())); + GameObject.Find(_id.ToString()).GetComponent().stat = 2; + //Destroy(GameObject.Find(_id.ToString())); } } }