DontDestroyComponent.cs 588 B

12345678910111213141516171819202122232425
  1. using UnityEngine;
  2. using System.Collections;
  3. namespace Engine.Component
  4. {
  5. /// <summary>标示某个gameobjec切换场景时不会被释放</summary>
  6. public class DontDestroyComponent : BaseComponent
  7. {
  8. /// <summary>初始化函数</summary>
  9. public override void Awake()
  10. {
  11. //gameObject切换场景时不被释放
  12. DontDestroyOnLoad(this.gameObject);
  13. base.Awake();
  14. }
  15. /// <summary>释放函数</summary>
  16. public override void Dispose()
  17. {
  18. base.Dispose();
  19. }
  20. }
  21. }