using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class movieController : MonoBehaviour { public float totalTime = 0.5f; public int id; public tuio_event tuio_event; public float fade_speed = 0.02f; public int stat; float c; Vector2 pos, pre_pos; void Start() { GetComponent().color = Color.clear; pos = Vector2.zero; } // Update is called once per frame void Update() { //Debug.Log(stat); pre_pos = pos; if (name == "RawImage") { GetComponent().enabled = false; } else { GetComponent().enabled = true; } if (tuio_event.tuio_input.touchCount > 0) { transform.gameObject.SetActive(true); if (stat == 1 && id >= 0) pos = tuio_event.tuio_input.GetTouch(id).position; else if (stat == 2) pos = pre_pos; GetComponent().position = new Vector3(pos.x, pos.y, 0); } if(stat == 1) { c += fade_speed; } else if (stat == 2) { 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() { stat = 1; c = 0f; Debug.Log("Hi"); } private void OnDestroy() { Debug.Log("Bye"); } }