private bool CheckEventHealth(Sandbox.SandboxEventInfo eventInfo) { if (eventInfo.callback == null) { return(false); } if (eventInfo.hasReference) { if (eventInfo.isReferenceUnityObject) { if (eventInfo.referenceObject as UnityEngine.Object == null) { return(false); } } else { if (eventInfo.referenceObject == null) { return(false); } } } return(true); }
private void DrawSanboxEvent(Sandbox.SandboxEventInfo sandboxInfo) { GUILayoutOption buttonWidth = GUILayout.Width(100); if (sandboxInfo == null) { SpiralEditor.BeginPanel(GroupType.Vertical, SpiralStyles.colorLightRed); EditorGUILayout.LabelField($"IDX {sandboxInfo.idx} broken entry", SpiralStyles.panel); if (SpiralEditor.Button("Kill callback", buttonWidth)) { Sandbox.RemoveCallback(sandboxInfo.idx); } EditorGUILayout.Space(2); SpiralEditor.EndPanel(); } else { bool good = CheckEventHealth(sandboxInfo); Color color; if (good) { color = sandboxInfo.paused ? SpiralStyles.colorLightYellow : SpiralStyles.colorLightGreen; } else { color = sandboxInfo.paused ? SpiralStyles.colorLightOrange : SpiralStyles.colorLightRed; } SpiralEditor.BeginPanel(GroupType.Vertical, color); string isPaused = sandboxInfo.paused ? "PAUSED" : "IS RUNNING"; EditorGUILayout.LabelField($"IDX {sandboxInfo.idx} {isPaused}", SpiralStyles.panel); EditorGUI.indentLevel += 1; GUI.enabled = false; if (sandboxInfo.hasReference) // имеет опорный объект { if (sandboxInfo.referenceObject != null) // опорный объект существует { if (sandboxInfo.isReferenceUnityObject) { _ = EditorGUILayout.ObjectField("UnityObject: ", sandboxInfo.referenceObject as UnityEngine.Object, sandboxInfo.referenceObjectType, true); } else { string name = "System.Object"; string data = $"{sandboxInfo.referenceObject} [{sandboxInfo.referenceObjectType}]"; EditorGUILayout.LabelField(name, data); } } else // опорный объект утерян { if (sandboxInfo.isReferenceUnityObject) { _ = EditorGUILayout.ObjectField("UnityObject: ", null, sandboxInfo.referenceObjectType, true); } else { string name = "System.Object"; string data = $"<missing> [{sandboxInfo.referenceObjectType}]"; EditorGUILayout.LabelField(name, data); } } } else // запуск без опорного объекта { EditorGUILayout.LabelField("No reference object"); } EditorGUILayout.LabelField("Sender Type", $"[{sandboxInfo.senderType}]"); string callbackName; object target = sandboxInfo.callback.Target; string parent = $"[{target}]"; callbackName = $"{sandboxInfo.callback.Method.Name} {parent}"; EditorGUILayout.LabelField("Method", $"{callbackName}"); EditorGUI.indentLevel -= 1; GUI.enabled = true; SpiralEditor.BeginGroup(GroupType.Horizontal); EditorGUILayout.Space(2); GUI.enabled = sandboxInfo.idx != Sandbox.sandboxTotalCount - 1; if (SpiralEditor.Button("Move Down", buttonWidth)) { Sandbox.MoveDown(sandboxInfo.idx); } GUI.enabled = true; EditorGUILayout.Space(2); if (SpiralEditor.Button("Kill callback", buttonWidth)) { Sandbox.RemoveCallback(sandboxInfo.idx); } string pause = sandboxInfo.paused ? "Unpause" : "Pause"; if (SpiralEditor.Button(pause, buttonWidth)) { if (sandboxInfo.paused) { Sandbox.UnpauseCallback(sandboxInfo.idx); } else { Sandbox.PauseCallback(sandboxInfo.idx); } } EditorGUILayout.Space(2); GUI.enabled = sandboxInfo.idx != 0; if (SpiralEditor.Button("Move Up", buttonWidth)) { Sandbox.MoveUp(sandboxInfo.idx); } GUI.enabled = true; EditorGUILayout.Space(2); SpiralEditor.EndGroup(); EditorGUILayout.Space(2); SpiralEditor.EndPanel(); } }