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.
101 lines
2.6 KiB
101 lines
2.6 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
using UnityEngine.UI;
|
|
using UltraCombos;
|
|
|
|
public class movieController : MonoBehaviour
|
|
{
|
|
//[RequireComponent(typeof(DShowMoviePlayer))]
|
|
DShowMoviePlayer player;
|
|
public int id;
|
|
public tuio_event tuio_event;
|
|
public float fade_speed = 0.02f;
|
|
public int stat;
|
|
float c;
|
|
Vector2 pos, pre_pos;
|
|
bool first_time = false;
|
|
|
|
void Awake()
|
|
{
|
|
player = GetComponent<DShowMoviePlayer>();
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
//player = GetComponent<DShowMoviePlayer>();
|
|
GetComponent<RawImage>().color = Color.clear;
|
|
pos = Vector2.zero;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
//Debug.Log(stat);
|
|
pre_pos = pos;
|
|
|
|
if (name == "RawImage")
|
|
{
|
|
GetComponent<RawImage>().enabled = false;
|
|
}
|
|
else
|
|
{
|
|
GetComponent<RawImage>().enabled = true;
|
|
}
|
|
|
|
bool _isLocked = tuio_event.isLocked;
|
|
if (tuio_event.tuio_input.touchCount > 0 && _isLocked == false && id != -1)
|
|
{
|
|
|
|
transform.gameObject.SetActive(true);
|
|
//////////////////////
|
|
int t_c = tuio_event.tuio_input.touchCount;
|
|
if (id == t_c)
|
|
{
|
|
id -= 1;
|
|
Debug.Log("error");
|
|
}
|
|
//Debug.Log("id = " + id + " / touch count = " + t_c);
|
|
if (stat == 1 && id >= 0 && id < t_c)
|
|
{
|
|
pos = tuio_event.tuio_input.GetTouch(id).position;
|
|
}
|
|
else if (stat == 2)
|
|
pos = pre_pos;
|
|
GetComponent<RectTransform>().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<RawImage>().color = new Color(1f, 1f, 1f, c);
|
|
}
|
|
|
|
void OnEnable()
|
|
{
|
|
Debug.Log("Hi");
|
|
stat = 1;
|
|
//c = 0f;
|
|
if (first_time == false)
|
|
{
|
|
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);
|
|
}
|
|
first_time = true;
|
|
}
|
|
|
|
void OnDestroy()
|
|
{
|
|
Debug.Log("Bye");
|
|
player.Stop();
|
|
}
|
|
}
|
|
|