SingletonBaseMono.cs 405 B

1234567891011121314151617181920
  1. using UnityEngine;
  2. /// <summary>
  3. /// µ¥Àý»ùÀ࣬¼Ì³Ðmono
  4. /// </summary>
  5. public class SingletonBaseMono<T> : MonoBehaviour where T : MonoBehaviour
  6. {
  7. private static T instance;
  8. public static T Instance
  9. {
  10. get
  11. {
  12. if (instance == null)
  13. {
  14. instance = GameObject.FindObjectOfType<T>();
  15. }
  16. return instance;
  17. }
  18. }
  19. }
粤ICP备19079148号