You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.1 KiB
94 lines
2.1 KiB
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;
|
|
float alpha;
|
|
|
|
void Awake()
|
|
{
|
|
player = GetComponent<DShowMoviePlayer>();
|
|
stat = 1;
|
|
force_destroy = false;
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
//player = GetComponent<DShowMoviePlayer>();
|
|
GetComponent<RawImage>().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 == 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<RawImage>().color = new Color(1f, 1f, 1f, alpha);
|
|
}
|
|
|
|
void OnEnable()
|
|
{
|
|
if (name != "RawImage") {
|
|
|
|
GetComponent<RawImage>().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<RectTransform>().position.x, GetComponent<RectTransform>().position.y, 0);
|
|
float rand_deg = Random.Range(0, 360);
|
|
GetComponent<RectTransform>().Rotate(rot_axis, rand_deg);
|
|
}
|
|
}
|
|
|