using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; using UltraCombos; public class movieController : MonoBehaviour { DShowMoviePlayer player; public int id; public float fade_speed = 0.02f; public int stat; public float alpha; public float destroy_timer; public bool CanDsetroy; float wait_sec = 2f; void Awake() { player = GetComponent(); CanDsetroy = true; stat = 1; } void Start() { //player = GetComponent(); GetComponent().color = Color.clear; } void Update() { if(stat == 0){ alpha = 0; stat = 1; } else if (stat == 1) { alpha += fade_speed; if (alpha >= 1) { alpha = 1; stat = 2; } } else if (stat == 3) { float t = Time.time; if (t - destroy_timer > wait_sec) { //Debug.Log("fade"); alpha -= fade_speed; if (alpha < 0 && CanDsetroy) { Destroy(this.gameObject); } } } GetComponent().color = new Color(1f, 1f, 1f, alpha); } void OnEnable() { if (name != "RawImage") { GetComponent().enabled = true; } //Debug.Log("Hi"); stat = 1; alpha = 0f; rotateImg(); } void OnDestroy() { //Debug.Log("Bye"); } public void rotateImg() { Vector3 rot_axis = new Vector3(0, 0, 1); Vector3 mid_pt = new Vector3(GetComponent().position.x, GetComponent().position.y, 0); float rand_deg = Random.Range(0, 360); GetComponent().Rotate(rot_axis, rand_deg); } }