summaryrefslogtreecommitdiff
path: root/Assets/Samples/XR Interaction Toolkit/3.1.2/Starter Assets/Scripts/DestroySelf.cs
blob: f10ffc415e3dc8c631d87b36d83459af9fb2a271 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
namespace UnityEngine.XR.Interaction.Toolkit.Samples.StarterAssets
{
    /// <summary>
    /// Destroys the GameObject it is attached to after a specified amount of time.
    /// </summary>
    public class DestroySelf : MonoBehaviour
    {
        [SerializeField]
        [Tooltip("The amount of time, in seconds, to wait after Start before destroying the GameObject.")]
        float m_Lifetime = 0.25f;

        /// <summary>
        /// The amount of time, in seconds, to wait after Start before destroying the GameObject.
        /// </summary>
        public float lifetime
        {
            get => m_Lifetime;
            set => m_Lifetime = value;
        }

        /// <summary>
        /// See <see cref="MonoBehaviour"/>.
        /// </summary>
        void Start()
        {
            Destroy(gameObject, m_Lifetime);
        }
    }
}