Guest User

Adventure creator optimisation

a guest
Mar 5th, 2015
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using AC;
  4. public class RSL_TurnNPCoffWhenInvisible : MonoBehaviour {
  5.  
  6.  
  7. bool showWorkings=false; //so we can verify if its working, DEBUG only
  8.  
  9. //works but needs to be on something with a renderer i think
  10. void OnBecameVisible() {
  11. if (showWorkings)
  12. {
  13. Debug.Log ("..OnBecameVisible "+name);
  14. }
  15.  
  16.  
  17. if (NPCcomponent==null)
  18. {
  19. Debug.Log("OnBecameInvisible-->NPCcomponent is null cant flag it as offscreen! "+name);
  20. return;
  21. }
  22. //now we get the npc so we can tell it that its offscreen
  23. NPCcomponent.isOffScreen=false;
  24. }
  25. void OnBecameInvisible() {
  26. if (showWorkings)
  27. {
  28. Debug.Log ("..OnBecameInvisible "+name);
  29. }
  30.  
  31. if (NPCcomponent==null)
  32. {
  33. Debug.Log("OnBecameInvisible-->NPCcomponent is null cant flag it as offscreen! "+name);
  34. return;
  35. }
  36. //now we get the npc so we can tell it that its offscreen
  37. NPCcomponent.isOffScreen=true;
  38.  
  39. }
  40.  
  41. NPC NPCcomponent;
  42.  
  43. // Use this for initialization
  44. void Start () {
  45.  
  46. GameObject npc = transform.parent.gameObject;
  47. NPCcomponent = npc.GetComponent<NPC>();
  48. }
  49.  
  50. // Update is called once per frame
  51. void Update ()
  52. {
  53.  
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment