csPrefebMake.cs 691 B

1234567891011121314151617181920212223242526272829303132
  1. using UnityEngine;
  2. using System.Collections;
  3. public class csPrefebMake : MonoBehaviour
  4. {
  5. public Transform MakePrefeb;
  6. Transform _MakePrefeb;
  7. public float DeadTime;
  8. void Start()
  9. {
  10. _MakePrefeb = Instantiate(MakePrefeb, transform.position, Quaternion.identity) as Transform;
  11. _MakePrefeb.transform.parent = transform;
  12. }
  13. void Update()
  14. {
  15. if(DeadTime<=0)
  16. return;
  17. if (_MakePrefeb)
  18. Destroy(_MakePrefeb.gameObject, DeadTime);
  19. else if (!_MakePrefeb)
  20. {
  21. _MakePrefeb = Instantiate(MakePrefeb, transform.position, Quaternion.identity) as Transform;
  22. _MakePrefeb.transform.parent = transform;
  23. }
  24. }
  25. }