Пример #1
0
        /// <summary>
        /// Starts the coroutine.
        /// </summary>
        /// <returns>If not forked, returns coroutine.</returns>
        /// <param name="ecoroutine">Coroutine method</param>
        /// <param name="obj">Start it on this gameObject. If null, start on coroutineManager gameObject.</param>
        /// <param name="forked">When parent coroutine will be stoped, this will remain.</param>
        /// <param name="id">Identifier used for kill coroutine with all notforked childrens.</param>
        /// <param name="onException">On exception call. Not implemented yet!</param>
        public UnityEngine.Coroutine StartCoroutine(IEnumerator ecoroutine, GameObject obj, bool forked, ObjectCrtn.MethodExceptionParam onException = null, bool destroyWithParent = true)
        {
            Debug.Assert(forked || ObjectCrtn.ActiveCoroutine != null, "Starting main coroutine " + ecoroutine + ", but no parent coroutine active.", true);
        #if USE_ORIGINAL_COROUTINES
            return(StartCoroutineOriginal(ecoroutine));
        #endif
            PurgeDeletedCoroutines();

            GameObject onGameObject    = obj ?? gameObject;          // if obj not defined, start it on this gameobject
            ObjectCrtn objectCoroutine = new ObjectCrtn(OnCoroutineEnd, ecoroutine, onException, onGameObject, forked ? null : ObjectCrtn.ActiveCoroutine);
            objectCoroutine.DestroyWithParent = destroyWithParent;
            UnityEngine.Coroutine coroutine = CreateCoroutine(objectCoroutine);

            return(forked ? null : coroutine);
        }
Пример #2
0
        /// <summary>
        /// Starts the coroutine ret.
        /// </summary>
        /// <returns>The coroutine ret.</returns>
        /// <param name="ecoroutine">Ecoroutine.</param>
        /// <param name="obj">Object.</param>
        /// <param name="ObjectRetCrtn">Object ret crtn.</param>
        /// <param name="onException">On exception.</param>
        /// <param name="id">Identifier.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        public UnityEngine.Coroutine StartCoroutineRet <T>(IEnumerator ecoroutine, GameObject obj, out ObjectRetCrtn <T> objectRetCrtn, ObjectCrtn.MethodExceptionParam onException = null, bool destroyWithParent = true)
        {
            PurgeDeletedCoroutines();

            GameObject onGameObject = obj ?? gameObject;             // if obj not defined, start it on this gameobject

            objectRetCrtn = new ObjectRetCrtn <T>(OnCoroutineEnd, ecoroutine, onException, onGameObject, ObjectCrtn.ActiveCoroutine);
            objectRetCrtn.DestroyWithParent = destroyWithParent;
        #if USE_ORIGINAL_COROUTINES
            return(StartCoroutineOriginal(ecoroutine));
        #endif
            return(CreateCoroutine(objectRetCrtn));
        }