PoolItem.cs 443 B

123456789101112131415161718192021
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PoolItem : MonoBehaviour
  5. {
  6. public GameObject prefab;
  7. private void OnDisable()
  8. {
  9. if (gameObject.activeSelf)
  10. {
  11. return;//防止是父物体去激活的情况
  12. }
  13. PoolManager.instance.Recycle(this);
  14. }
  15. private void OnDestroy()
  16. {
  17. PoolManager.instance.DestroyItem(this);
  18. }
  19. }