public static Coroutine StartCoroutine(object obj, IEnumerator coroutine, CoroutineGroup group, string tag = null, bool pool = Coroutine.PoolByDefault) { Coroutine result = null; UObject ownerObj = obj as UObject; if (ownerObj != null) { IntPtr world = Native_UObject.GetWorld(ownerObj.Address); Debug.Assert(world != IntPtr.Zero, "UObject coroutines must be objects with a UWorld reference (e.g. AActor) - " + "this is so that the coroutine can be stopped when the world is destroyed."); } // Let the caller do this check /*if (!FThreading.IsInGameThread()) * { * FThreading.RunOnGameThread(delegate () { result = StartCoroutine(obj, coroutine, group, tag, pool); }); * return result; * }*/ if (pool) { result = CoroutinePool.New(coroutine); } else { result = new Coroutine(coroutine); } result.Owner = obj; result.Group = group; result.mainCollectionIndex = coroutines.Count; result.Tag = tag; coroutines.Add(result); if (ownerObj != null) { List <Coroutine> collection; if (!coroutinesByObject.TryGetValue(ownerObj, out collection)) { coroutinesByObject.Add(ownerObj, collection = new List <Coroutine>()); } result.objectsCollectionIndex = collection.Count; collection.Add(result); } if (!string.IsNullOrEmpty(tag)) { List <Coroutine> collection; if (!coroutinesByTag.TryGetValue(tag, out collection)) { coroutinesByTag.Add(tag, collection = new List <Coroutine>()); } result.tagsCollectionIndex = collection.Count; collection.Add(result); } return(result); }
public static Coroutine StartCoroutine(object obj, IEnumerator coroutine, CoroutineGroup group, string tag = null, bool pool = Coroutine.PoolByDefault) { Coroutine result = null; // Let the caller do this check /*if (!FThreading.IsInGameThread()) * { * FThreading.RunOnGameThread(delegate () { result = StartCoroutine(obj, coroutine, group, tag, pool); }); * return result; * }*/ if (pool) { result = CoroutinePool.New(coroutine); } else { result = new Coroutine(coroutine); } result.Owner = obj; result.Group = group; result.Tag = tag; result.mainCollectionIndex = coroutines.Count; coroutines.Add(result); return(result); }