void Loop(Process process) { for (int i = 0; i < behaviours.Count;) { CoexBehaviour b = behaviours[i]; if (null == b) { // NOTICE: this is a interesting part, b is not really null // regarding to .NET, we're making use of unity's overload version // of null condition test. // // and StopAllCoroutines must be called on b at this point, or else // dangling Coex which is started by b will probably has a state // other than Interrupt, could be Running or something else. b.StopAllCoroutines(); b.Clear(); behaviours.RemoveAt(i); continue; } if (!b.Loop(process)) { b.addToEngine = false; behaviours.RemoveAt(i); continue; } else { ++i; } } }
internal void AddBehaviour(CoexBehaviour b) { if (!behaviours.Contains(b)) { behaviours.Add(b); } }
public override void OnInspectorGUI() { CoexBehaviour script = (CoexBehaviour)target; float labelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 95f; EditorGUILayout.LabelField("AddToEngine: " + script.addToEngine); if (script.coexCount > 0) { if (foldoutList = EditorGUILayout.Foldout(foldoutList, string.Format("Coroutines({0})", script.coexCount))) { for (int p = 0; p < script.coexs.Length; ++p) { EditorGUILayout.LabelField(string.Format("{0}:", (CoexEngine.Process)p)); ++EditorGUI.indentLevel; var list = script.coexs[p]; for (int i = 0; i < list.Count; ++i) { Coex c = list[i]; if (c.foldout = EditorGUILayout.Foldout(c.foldout, c.routineName)) { if (null != c.returnValueType) { EditorGUILayout.LabelField("return type:", c.returnValueType.FullName); } if (null != c.returnValue) { EditorGUILayout.LabelField("last return:", c.returnValue.ToString()); } EditorGUILayout.LabelField("yield count:", c.yieldCount.ToString()); } } --EditorGUI.indentLevel; } } } EditorGUIUtility.labelWidth = labelWidth; }