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.

74 lines
1.7 KiB

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;
6 years ago
public float fade_speed = 0.02f;
public int stat;
6 years ago
Vector2 final_size;
6 years ago
float c;
Vector2 pos, pre_pos;
//public Transform trans;
// Start is called before the first frame update
void Start()
{
6 years ago
final_size = GetComponent<RectTransform>().sizeDelta;
GetComponent<RawImage>().color = Color.clear;
pos = Vector2.zero;
}
// Update is called once per frame
void Update()
{
6 years ago
//Debug.Log(stat);
pre_pos = pos;
if (name == "RawImage")
{
GetComponent<RawImage>().enabled = false;
}
else
{
GetComponent<RawImage>().enabled = true;
}
if (tuio_event.tuio_input.touchCount > 0)
{
transform.gameObject.SetActive(true);
6 years ago
if (stat == 1)
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);
6 years ago
}
if(stat == 1)
{
c += fade_speed;
}
else if (stat == 2)
{
6 years ago
c -= fade_speed;
if (c < 0f) Destroy(gameObject);
}
6 years ago
c = Mathf.Clamp(c, 0f, 1f);
GetComponent<RawImage>().color = new Color(1f, 1f, 1f, c);
}
private void OnEnable()
{
6 years ago
stat = 1;
c = 0f;
Debug.Log("Hi");
}
private void OnDestroy()
{
Debug.Log("Bye");
}
}