1 using System;
2 using
UnityEngine;
3
4 namespace
UnityStandardAssets.Utility
5 {
6     
public class TimedObjectDestructor : MonoBehaviour
7     {
8         [SerializeField]
private float m_TimeOut = 1.0f;
9         [SerializeField]
private bool m_DetachChildren = false;
10
11
12         
private void Awake()
13         {
14             Invoke(
"DestroyNow", m_TimeOut);
15         }
16
17
18         
private void DestroyNow()
19         {
20             
if (m_DetachChildren)
21             {
22                 transform.DetachChildren();
23             }
24             DestroyObject(gameObject);
25         }
26     }
27 }


Gõ tìm kiếm nhanh...