Advertisement
Guest User

Untitled

a guest
May 30th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1.  
  2. public class InfoText : MonoBehaviour {
  3.  
  4. private GameObject Text;
  5.  
  6. public int timeActive;
  7.  
  8. public string TextContent;
  9.  
  10. void Start()
  11. {
  12. Text = GameObject.Find ("InfoText");
  13. Text.GetComponent<Text>().text = TextContent;
  14. Text.SetActive (false);
  15.  
  16. }
  17.  
  18. void OnTriggerEnter(Collider other)
  19. {
  20. if (other.transform.name == "cowboy_game_player")
  21. {
  22. Text.SetActive (true);
  23. }
  24. }
  25.  
  26. void OnTriggerStay(Collider other)
  27. {
  28. if (other.transform.name == "cowboy_game_player")
  29. {
  30. Text.SetActive (true);
  31. }
  32. }
  33.  
  34. void OnTriggerExit(Collider other)
  35. {
  36. if (other.transform.name == "cowboy_game_player")
  37. {
  38. Invoke ("manualDeactivate", timeActive);
  39. }
  40. }
  41.  
  42. void manualDeactivate()
  43. {
  44. Text.SetActive (false);
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement