// ------------------------------------------------------------------------------- void ShowActionInspector() { EditorGUILayout.Space(); EditorGUILayout.LabelField(mCurrentAction.GetType().Name, EditorStyles.boldLabel); EditorGUILayout.Space(); // Actions can control their own GUI, or we can just do a generic version ourselves if (!mCurrentAction.OnGUI()) { // Show inspector GUI for all public fields on the CurrentAction foreach (FieldInfo fieldInfo in mCurrentAction.GetType().GetFields()) { if (fieldInfo != null && !fieldInfo.IsStatic) { var value = fieldInfo.GetValue(mCurrentAction); value = EditorGUIHelper.ShowInspectorForType(fieldInfo.FieldType, value, fieldInfo.Name); fieldInfo.SetValue(mCurrentAction, value); } } } if (GUILayout.Button("Copy Action")) { ActionGraphEditor.CopiedAction = mCurrentAction.Clone(); } }
// ------------------------------------------------------------------------------- void ShowConnectionInspector(Connection connection) { EditorGUILayout.Space(); EditorGUILayout.LabelField(connection.StartNode.Name + " -> " + connection.EndNode.Name, EditorStyles.boldLabel); EditorGUILayout.Space(); connection.ConditionRequirement = (Connection.ConditionRequirements)EditorGUILayout.EnumPopup("Condition Requirements", connection.ConditionRequirement); EditorGUILayout.Space(); EditorGUIHelper.CreateConditionButton((condition) => { connection.Conditions.Add(condition as Condition); }); EditorGUILayout.Space(); EditorGUILayout.LabelField("CONDITIONS", EditorStyles.boldLabel); if (connection.Conditions == null || connection.Conditions.Count == 0) { EditorGUILayout.LabelField("None! This connection will transition automatically."); } else { Condition conditionToDelete = null; foreach (var condition in connection.Conditions) { EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(condition.ToString(), EditorStyles.boldLabel); if (GUILayout.Button("Delete")) { conditionToDelete = condition; break; } EditorGUILayout.EndHorizontal(); // Show inspector GUI for all public fields on the Condition EditorGUIHelper.ShowConditionInspector(condition); } if (conditionToDelete != null) { connection.Conditions.Remove(conditionToDelete); conditionToDelete = null; } } EditorGUILayout.Space(); if (GUILayout.Button("*DELETE CONNECTION*")) { connection.StartNode.OutgoingConnections.Remove(connection); connection.EndNode.IncomingConnections.Remove(connection); if (connection == mCurrentConnection) { mCurrentConnection = null; } return; } }