/// <summary>
        /// Creates a new MonoBehaviourHelper object and returns it in order for the client to use.
        /// </summary>
        public static MonoBehaviourHelper CreateTemporaryMonoBehaviour(float?lifeTime, string name = null)
        {
            GameObject          go = new GameObject(name ?? "Mono Behaviour Helper", typeof(MonoBehaviourHelper));
            MonoBehaviourHelper monoBehaviourHelper = go.GetComponent <MonoBehaviourHelper>();

            if (lifeTime != null)
            {
                Destroy(go, (float)lifeTime);
            }
            return(monoBehaviourHelper);
        }
Пример #2
0
 /// <summary>
 /// Puts the object to the pool after given time.
 /// </summary>
 public void PutObjectAfter(T item, float time)
 {
     //time + 1 because computer must be finished putting the object back to pool and then destroy the MonoBehaviourHelper
     MonoBehaviourHelper.CreateTemporaryMonoBehaviour(time + 1).StartCoroutine(ObjectLifeControllerCoroutine(item, time));
 }
Пример #3
0
 public static void FadeOut(this AudioSource audioSource, float fadeTime)
 {
     MonoBehaviourHelper.CreateTemporaryMonoBehaviour(fadeTime).StartCoroutine(FadeOutCoroutine(audioSource, fadeTime));
 }