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 int stat; public float fade_speed; public bool force_destroy; public float destroy_timer; public float wait_sec = 2f; public DShowClip snow_01; public DShowClip snow_02; public DShowClip snow_03; public DShowClip snow_04; float alpha; void Awake() { player = GetComponent(); stat = 0; force_destroy = false; } void Start() { //player = GetComponent(); GetComponent().color = Color.clear; } void Update() { if(stat == 0){ alpha = 0; if (player.IsPlaying) stat = 1; } else if (stat == 1) { alpha += fade_speed * 5f; if (alpha >= 1) { alpha = 1; stat = 2; } } else if (stat == 2 && force_destroy) { stat = 3; } else if (stat == 3) { float t = Time.time; if (t - destroy_timer > wait_sec) { //Debug.Log("fade"); alpha -= fade_speed; if (alpha < 0) { Destroy(this.gameObject); } } } GetComponent().color = new Color(1f, 1f, 1f, alpha); } void OnEnable() { int seed = Random.Range(0, 4); switch (seed){ case 0: player.VideoAsset = snow_01; break; case 1: player.VideoAsset = snow_02; break; case 2: player.VideoAsset = snow_03; break; case 3: player.VideoAsset = snow_04; break; } if (name != "RawImage") { GetComponent().enabled = true; } //Debug.Log("Hi"); stat = 0; alpha = 0f; rotateImg(); player.Play(); } 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); } }