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

  1. namespace Oculus.Platform.Samples.VrHoops
  2. {
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using System.Collections;
  6. // helper script to render fading flytext above an object
  7. public class FlyText : MonoBehaviour
  8. {
  9. // destory the gameobject after this many seconds
  10. private const float LIFESPAN = 3.0f;
  11. // how far to move upwards per frame
  12. private readonly Vector3 m_movePerFrame = 0.5f * Vector3.up;
  13. // actual destruction time
  14. private float m_eol;
  15. void Start()
  16. {
  17. m_eol = Time.time + LIFESPAN;
  18. GetComponent<Text>().CrossFadeColor(Color.black, LIFESPAN * 1.7f, false, true);
  19. }
  20. void Update()
  21. {
  22. if (Time.time < m_eol)
  23. {
  24. transform.localPosition += m_movePerFrame;
  25. }
  26. else
  27. {
  28. Destroy(gameObject);
  29. }
  30. }
  31. }
  32. }