Advertisement
LittleAngel

Controller Reference Support

Jul 24th, 2012
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #region Reference Support
  2. private static MyController myController;
  3. // Reference Support:MyController
  4. // MyController can be cached on start as private MyController myController;
  5. // & in Start() myController = MyController.Instance();
  6.  
  7. public static MyController Instance () {
  8. if (!myController) {
  9. myController = FindObjectOfType(typeof (MyController)) as MyController;
  10. if (!myController)
  11. Debug.LogError ("There needs to be one active MyController script on a GameObject in your scene.");
  12. }
  13.  
  14. return myController;
  15. }
  16. #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement