KairoEngineManager.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Events;
  5. namespace KairoEngine.Core
  6. {
  7. /// <summary>
  8. /// The main script that loads all the kairoEngine modules to the game.
  9. /// This is the only required script to put on one game object to start the engine.
  10. /// </summary>
  11. public class KairoEngineManager : MonoBehaviour
  12. {
  13. private static KairoEngineManager kairoEngine;
  14. public static KairoEngineManager instance
  15. {
  16. get {
  17. if(!kairoEngine)
  18. {
  19. kairoEngine = FindObjectOfType (typeof(KairoEngineManager)) as KairoEngineManager;
  20. if(!kairoEngine)
  21. {
  22. Debug.LogError("There need to one active KairoEngine script on the scene.");
  23. return null;
  24. }
  25. }
  26. return kairoEngine;
  27. }
  28. }
  29. void Awake()
  30. {
  31. if(instance != null && instance != this) Destroy(this.gameObject);
  32. DontDestroyOnLoad(gameObject);
  33. }
  34. }
  35. }