Guest User

Untitled

a guest
Jan 17th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. [KnMethod(null, "DirtyCachedAITagsForUI", null, false)]
  2.  
  3. public class AIManager : MonoBehaviour
  4. {
  5. static AIManager singleton;
  6.  
  7. public string[] AITags;
  8. #region AI Tag caching
  9. protected List<GUIContent> cachedAITagsforUI;
  10. bool cachedAITagsforUIDirty = true;
  11. #endregion
  12.  
  13. void Start()
  14. {
  15. if (singleton != null) { Debug.LogError("You have multiple AIManager in the scene. Knock that crap off, or shit gunna get weird."); }
  16. singleton = this;
  17. }
  18.  
  19. #region AI Tag caching
  20. public void DirtyCachedAITagsForUI()
  21. {
  22. cachedAITagsforUIDirty = true;
  23. }
  24.  
  25. // (please never call this anywhere but in the editor)
  26. static public List<GUIContent> GetAITagsForUI()
  27. {
  28. // (we HAVE to do this, because this gets called in editor, so Start has never been called)
  29. if (singleton == null) { singleton = FindObjectOfType<AIManager>(); }
  30.  
  31. if (singleton.cachedAITagsforUIDirty)
  32. {
  33. singleton.cachedAITagsforUI = new List<GUIContent>();
  34. foreach (string aiTag in singleton.AITags)
  35. {
  36. singleton.cachedAITagsforUI.Add(new GUIContent(aiTag));
  37. }
  38. singleton.cachedAITagsforUIDirty = false;
  39. }
  40. return singleton.cachedAITagsforUI;
  41. }
  42. #endregion
  43. }
Advertisement
Add Comment
Please, Sign In to add comment