Assignment for RMIT Mixed Reality in 2020
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.
 
 
 

37 lines
758 B

namespace Oculus.Platform.Samples.VrHoops
{
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
// helper script to render fading flytext above an object
public class FlyText : MonoBehaviour
{
// destory the gameobject after this many seconds
private const float LIFESPAN = 3.0f;
// how far to move upwards per frame
private readonly Vector3 m_movePerFrame = 0.5f * Vector3.up;
// actual destruction time
private float m_eol;
void Start()
{
m_eol = Time.time + LIFESPAN;
GetComponent<Text>().CrossFadeColor(Color.black, LIFESPAN * 1.7f, false, true);
}
void Update()
{
if (Time.time < m_eol)
{
transform.localPosition += m_movePerFrame;
}
else
{
Destroy(gameObject);
}
}
}
}