public override void DrawWindow(BaseNode pBaseNode) { if (pBaseNode._StateNodeRef._CurrentState == null) { EditorGUILayout.LabelField("Add state."); } else { if (!pBaseNode._Collapse) { } else { pBaseNode._WindowRect.height = 100; } pBaseNode._Collapse = EditorGUILayout.Toggle(" ", pBaseNode._Collapse); } pBaseNode._StateNodeRef._CurrentState = (State)EditorGUILayout.ObjectField(pBaseNode._StateNodeRef._CurrentState, typeof(State), false); if (pBaseNode._PreviousCollapse != pBaseNode._Collapse) { pBaseNode._PreviousCollapse = pBaseNode._Collapse; } if (pBaseNode._StateNodeRef._PreviousState != pBaseNode._StateNodeRef._CurrentState) { pBaseNode._IsDuplicate = BehaviorEditor._EditorSettings._CurrentGraph.IsStateNodeDuplicate(pBaseNode); pBaseNode._StateNodeRef._PreviousState = pBaseNode._StateNodeRef._CurrentState; if (!pBaseNode._IsDuplicate) { Vector3 InPosition = new Vector3(pBaseNode._WindowRect.x, pBaseNode._WindowRect.y, 0); InPosition.x += pBaseNode._WindowRect.width * 2; SetupReorderableList(pBaseNode); for (int i = 0; i < pBaseNode._StateNodeRef._CurrentState._Transition.Count; i++) { InPosition.y += i * 100; BehaviorEditor.AddTransitionNodeFromTransition(pBaseNode._StateNodeRef._CurrentState._Transition[i], pBaseNode, InPosition); } BehaviorEditor._ForceSetDirty = true; } } if (pBaseNode._IsDuplicate) { EditorGUILayout.LabelField("State is duplicate."); pBaseNode._WindowRect.height = 100; return; } if (pBaseNode._StateNodeRef._CurrentState != null) { pBaseNode._IsAssigned = true; if (!pBaseNode._Collapse) { if (pBaseNode._StateNodeRef._SerializedState == null) { SetupReorderableList(pBaseNode); } float standard = 150; pBaseNode._StateNodeRef._SerializedState.Update(); pBaseNode._ShowActions = EditorGUILayout.Toggle("Show Actions ", pBaseNode._ShowActions); if (pBaseNode._ShowActions) { EditorGUILayout.LabelField(""); pBaseNode._StateNodeRef._OnFixedList.DoLayoutList(); EditorGUILayout.LabelField(""); pBaseNode._StateNodeRef._OnUpdateList.DoLayoutList(); standard += 100 + 40 + (pBaseNode._StateNodeRef._OnUpdateList.count + pBaseNode._StateNodeRef._OnFixedList.count) * 20; } pBaseNode._ShowEnterExit = EditorGUILayout.Toggle("Show Enter/Exit ", pBaseNode._ShowEnterExit); if (pBaseNode._ShowEnterExit) { EditorGUILayout.LabelField(""); pBaseNode._StateNodeRef._OnEnterList.DoLayoutList(); EditorGUILayout.LabelField(""); pBaseNode._StateNodeRef._OnExitList.DoLayoutList(); standard += 100 + 40 + (pBaseNode._StateNodeRef._OnEnterList.count + pBaseNode._StateNodeRef._OnExitList.count) * 20; } pBaseNode._StateNodeRef._SerializedState.ApplyModifiedProperties(); pBaseNode._WindowRect.height = standard; } } else { pBaseNode._IsAssigned = false; } }
private static void ShowEditor() { BehaviorEditor InEditor = EditorWindow.GetWindow <BehaviorEditor>(); InEditor.minSize = new Vector2(800, 600); }
public override void DrawCurve(BaseNode pBaseNode) { Rect InRect = pBaseNode._WindowRect; InRect.y += pBaseNode._WindowRect.height * 0.5f; InRect.width = 1; InRect.height = 1; BaseNode InEnterNode = BehaviorEditor._EditorSettings._CurrentGraph.GetNodeWithIndex(pBaseNode._EnterNode); if (InEnterNode == null) { BehaviorEditor._EditorSettings._CurrentGraph.DeleteNode(pBaseNode._Id); } else { Color InTargetColor = Color.green; if (!pBaseNode._IsAssigned || pBaseNode._IsDuplicate) { InTargetColor = Color.red; } Rect InRect1 = InEnterNode._WindowRect; BehaviorEditor.DrawNodeCurve(InRect1, InRect, true, InTargetColor); } if (pBaseNode._IsDuplicate) { return; } if (pBaseNode._TargetNode > 0) { BaseNode InTargetNode = BehaviorEditor._EditorSettings._CurrentGraph.GetNodeWithIndex(pBaseNode._TargetNode); if (InTargetNode == null) { pBaseNode._TargetNode = -1; } else { InRect = pBaseNode._WindowRect; InRect.x += InRect.width; Rect InEndRect = InTargetNode._WindowRect; InEndRect.x -= InEndRect.width * 0.5f; Color InTargetColor = Color.green; if (InTargetNode._DrawNode is StateNode) { if (!InTargetNode._IsAssigned || InTargetNode._IsDuplicate) { InTargetColor = Color.red; } } else { if (!InTargetNode._IsAssigned) { InTargetColor = Color.red; } else { InTargetColor = Color.yellow; } } BehaviorEditor.DrawNodeCurve(InRect, InEndRect, false, InTargetColor); } } }