/// <summary> /// Renders the currently selected step /// </summary> /// <param name="rStep"></param> private bool DrawActionDetailItem(NodeLinkAction rItem) { bool lIsDirty = false; if (rItem == null) { EditorGUILayout.LabelField("NULL"); return(false); } string lDescription = BaseDescriptionAttribute.GetDescription(rItem.GetType()); if (lDescription.Length > 0) { NodeEditorStyle.DrawInspectorDescription(lDescription, MessageType.None); } // Render out the action specific inspectors bool lIsActionDirty = rItem.OnInspectorGUI(mTarget); if (lIsActionDirty) { lIsDirty = true; } if (lIsDirty) { EditorUtility.SetDirty(rItem); } return(lIsDirty); }
/// <summary> /// Grab the types from the assembly /// </summary> public void RefreshList() { mTypes.Clear(); mNames.Clear(); mDescriptions.Clear(); mSelectedItemIndex = -1; if (mBaseType == null) { return; } // Generate the list of motions to display Assembly lAssembly = Assembly.GetAssembly(mBaseType); Type[] lMotionTypes = lAssembly.GetTypes().OrderBy(x => x.Name).ToArray <Type>(); for (int i = 0; i < lMotionTypes.Length; i++) { Type lType = lMotionTypes[i]; if (lType.IsAbstract) { continue; } if (!mBaseType.IsAssignableFrom(lType)) { continue; } string lFriendlyName = BaseNameAttribute.GetName(lType); if (mSearchString.Length > 0) { if (lFriendlyName.IndexOf(mSearchString) < 0) { if (lType.Name.IndexOf(mSearchString) < 0) { continue; } } } string lDescription = BaseDescriptionAttribute.GetDescription(lType); mTypes.Add(lType); mNames.Add(lFriendlyName); mDescriptions.Add(lDescription); } }
/// <summary> /// Renders the currently selected step /// </summary> /// <param name="rStep"></param> private bool DrawReactorDetailItem(ReactorAction rItem) { bool lIsDirty = false; if (rItem == null) { EditorGUILayout.LabelField("NULL"); return(false); } if (rItem.Name.Length > 0) { EditorHelper.DrawSmallTitle(rItem.Name.Length > 0 ? rItem.Name : "Actor Core Reactor"); } else { string lName = BaseNameAttribute.GetName(rItem.GetType()); EditorHelper.DrawSmallTitle(lName.Length > 0 ? lName : "Actor Core Reactor"); } string lDescription = BaseDescriptionAttribute.GetDescription(rItem.GetType()); if (lDescription.Length > 0) { EditorHelper.DrawInspectorDescription(lDescription, MessageType.None); } if (EditorHelper.TextField("Name", "Friendly name of the reactor", rItem.Name, mTarget)) { lIsDirty = true; rItem.Name = EditorHelper.FieldStringValue; } // Render out the Reactor specific inspectors bool lIsReactorDirty = rItem.OnInspectorGUI(mTargetSO, mTarget); if (lIsReactorDirty) { lIsDirty = true; } if (lIsDirty) { mTarget._ReactorDefinitions[mReactorList.index] = rItem.Serialize(); } return(lIsDirty); }
/// <summary> /// Draws in the content area of the window /// </summary> public override void DrawContent() { if (Editor.Canvas.SelectedNode == null) { return; } bool lIsDirty = false; if (Editor.Canvas.SelectedNode.Content != null) { string lDescription = BaseDescriptionAttribute.GetDescription(Editor.Canvas.SelectedNode.Content.GetType()); if (lDescription != null && lDescription.Length > 0) { NodeEditorStyle.DrawInspectorDescription(lDescription, MessageType.None); } } GUILayout.BeginHorizontal(); if (EditorHelper.BoolField("Is Start Node", "Determines if the node is used as a starting node.", Editor.Canvas.SelectedNode.IsStartNode, Editor.RootAsset)) { lIsDirty = true; Editor.Canvas.SelectedNode.IsStartNode = EditorHelper.FieldBoolValue; Spell lSpell = ((SpellEditor)Editor).Spell; if (lSpell != null) { if (lSpell.StartNodes == null) { lSpell.StartNodes = new System.Collections.Generic.List <Node>(); } if (lSpell.StartNodes.Contains(Editor.Canvas.SelectedNode)) { if (!Editor.Canvas.SelectedNode.IsStartNode) { lSpell.StartNodes.Remove(Editor.Canvas.SelectedNode); UnityEditor.EditorUtility.SetDirty(lSpell); } } else if (Editor.Canvas.SelectedNode.IsStartNode) { lSpell.StartNodes.Add(Editor.Canvas.SelectedNode); UnityEditor.EditorUtility.SetDirty(lSpell); } } } EditorHelper.LabelField("End Node", "Determines if the node is used as an ending node.", 60f); if (EditorHelper.BoolField(Editor.Canvas.SelectedNode.IsEndNode, "End Node", Editor.RootAsset, 16f)) { lIsDirty = true; Editor.Canvas.SelectedNode.IsEndNode = EditorHelper.FieldBoolValue; Spell lSpell = ((SpellEditor)Editor).Spell; if (lSpell != null) { if (lSpell.EndNodes == null) { lSpell.EndNodes = new System.Collections.Generic.List <Node>(); } if (lSpell.EndNodes.Contains(Editor.Canvas.SelectedNode)) { if (!Editor.Canvas.SelectedNode.IsEndNode) { lSpell.EndNodes.Remove(Editor.Canvas.SelectedNode); UnityEditor.EditorUtility.SetDirty(lSpell); } } else if (Editor.Canvas.SelectedNode.IsEndNode) { lSpell.EndNodes.Add(Editor.Canvas.SelectedNode); UnityEditor.EditorUtility.SetDirty(lSpell); } } } GUILayout.EndHorizontal(); if (Editor.Canvas.SelectedNode.Content == null) { EditorGUILayout.HelpBox(" Select an action for this node to take. Actions will be used to drive how the spell works.", MessageType.None); if (GUILayout.Button(new GUIContent("Select"))) { TypeSelectWindow lWindow = EditorWindow.GetWindow(typeof(TypeSelectWindow), false, "Select", true) as TypeSelectWindow; lWindow.BaseType = typeof(SpellAction); lWindow.SelectedEvent = OnTypeSelected; } } else { SpellAction lAction = Editor.Canvas.SelectedNode.Content as SpellAction; if (lAction != null) { bool lIsActionDirty = lAction.OnInspectorGUI(Editor.RootAsset); if (lIsActionDirty) { lIsDirty = true; } } } // If the node is dirty, we need to report it if (lIsDirty) { UnityEditor.EditorUtility.SetDirty(Editor.Canvas.SelectedNode); if (Editor.Canvas.SelectedNode._Content != null) { UnityEditor.EditorUtility.SetDirty(Editor.Canvas.SelectedNode._Content); } Editor.SetDirty(); } }
/// <summary> /// Gathers the master list of items and categories /// </summary> /// <param name="rItems">MotionSelectItems that represent the motion types</param> /// <param name="rTags">Tag strings</param> /// <returns></returns> public static int GetMasterMotionTypes(List <MotionSelectType> rTypes) { Type lBaseType = typeof(MotionControllerMotion); rTypes.Clear(); //rTypeTags.Clear(); // CDL 06/28/2018 - this only scans the "ootii" assembly //// Generate the list of motions to display //Assembly lAssembly = Assembly.GetAssembly(lBaseType); //Type[] lMotionTypes = lAssembly.GetTypes().OrderBy(x => x.Name).ToArray<Type>(); //for (int i = 0; i < lMotionTypes.Length; i++) //{ // Type lType = lMotionTypes[i]; // if (lType.IsAbstract) { continue; } // if (!lBaseType.IsAssignableFrom(lType)) { continue; } // string lName = MotionNameAttribute.GetName(lType); // if (lName == null || lName.Length == 0) { lName = BaseNameAttribute.GetName(lType); } // string lDescription = MotionDescriptionAttribute.GetDescription(lType); // if (lDescription == null || lDescription.Length == 0) { lDescription = BaseDescriptionAttribute.GetDescription(lType); } // string lTypeTags = MotionTypeTagsAttribute.GetTypeTags(lType); // MotionSelectType lItem = new MotionSelectType(); // lItem.Type = lType; // lItem.Path = lType.Name + ".cs"; // //string[] lFolders = System.IO.Directory.GetFiles(Application.dataPath, lItem.Path, System.IO.SearchOption.AllDirectories); // //if (lFolders.Length > 0) { lItem.Path = lFolders[0]; } // lItem.Name = lName; // lItem.Description = lDescription; // lItem.TypeTags = lTypeTags; // lItem.TypeTagArray = lTypeTags.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); // rTypes.Add(lItem); // //// Create the type tags // //if (lItem.TypeTagArray != null) // //{ // // for (int j = 0; j < lItem.TypeTagArray.Length; j++) // // { // // bool lIsFound = false; // // for (int k = 0; k < rTypeTags.Count; k++) // // { // // if (string.Compare(rTypeTags[k].Tag, lItem.TypeTagArray[j], true) == 0) // // { // // lIsFound = true; // // break; // // } // // } // // if (!lIsFound) // // { // // MotionSelectTypeTag lTypeTag = new MotionSelectTypeTag(); // // lTypeTag.Tag = lItem.TypeTagArray[j]; // // rTypeTags.Add(lTypeTag); // // } // // } // //} //} // CDL 06 / 28 / 2018 - scan all assemblies for Motions List <Type> lFoundTypes = AssemblyHelper.FoundTypes; // Generate the list of Motions to display for (int i = 0; i < lFoundTypes.Count; i++) { Type lType = lFoundTypes[i]; if (lType.IsAbstract) { continue; } if (!lBaseType.IsAssignableFrom(lType)) { continue; } string lName = MotionNameAttribute.GetName(lType); if (lName == null || lName.Length == 0) { lName = BaseNameAttribute.GetName(lType); } string lDescription = MotionDescriptionAttribute.GetDescription(lType); if (lDescription == null || lDescription.Length == 0) { lDescription = BaseDescriptionAttribute.GetDescription(lType); } string lTypeTags = MotionTypeTagsAttribute.GetTypeTags(lType); MotionSelectType lItem = new MotionSelectType(); lItem.Type = lType; lItem.Path = lType.Name + ".cs"; //string[] lFolders = System.IO.Directory.GetFiles(Application.dataPath, lItem.Path, System.IO.SearchOption.AllDirectories); //if (lFolders.Length > 0) { lItem.Path = lFolders[0]; } lItem.Name = lName; lItem.Description = lDescription; lItem.TypeTags = lTypeTags; lItem.TypeTagArray = lTypeTags.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); rTypes.Add(lItem); //// Create the type tags //if (lItem.TypeTagArray != null) //{ // for (int j = 0; j < lItem.TypeTagArray.Length; j++) // { // bool lIsFound = false; // for (int k = 0; k < rTypeTags.Count; k++) // { // if (string.Compare(rTypeTags[k].Tag, lItem.TypeTagArray[j], true) == 0) // { // lIsFound = true; // break; // } // } // if (!lIsFound) // { // MotionSelectTypeTag lTypeTag = new MotionSelectTypeTag(); // lTypeTag.Tag = lItem.TypeTagArray[j]; // rTypeTags.Add(lTypeTag); // } // } //} } return(rTypes.Count); }
/// <summary> /// Grab the types from the assembly /// </summary> public void RefreshList() { mTypes.Clear(); mNames.Clear(); mDescriptions.Clear(); mSelectedItemIndex = -1; if (mBaseType == null) { return; } // CDL 07/04/2018 - this only looks in the assembly containing the base type //// Generate the list of motions to display //Assembly lAssembly = Assembly.GetAssembly(mBaseType); //Type[] lMotionTypes = lAssembly.GetTypes().OrderBy(x => x.Name).ToArray<Type>(); //for (int i = 0; i < lMotionTypes.Length; i++) //{ // Type lType = lMotionTypes[i]; // if (lType.IsAbstract) { continue; } // if (!mBaseType.IsAssignableFrom(lType)) { continue; } // string lFriendlyName = BaseNameAttribute.GetName(lType); // if (mSearchString.Length > 0) // { // if (lFriendlyName.IndexOf(mSearchString) < 0) // { // if (lType.Name.IndexOf(mSearchString) < 0) // { // continue; // } // } // } // string lDescription = BaseDescriptionAttribute.GetDescription(lType); // mTypes.Add(lType); // mNames.Add(lFriendlyName); // mDescriptions.Add(lDescription); //} // CDL 07/04/2018 - used the cached found types from all assemblies // Create the list to display List <Type> lFoundTypes = AssemblyHelper.FoundTypes; for (int i = 0; i < lFoundTypes.Count; i++) { Type lType = lFoundTypes[i]; if (lType.IsAbstract) { continue; } if (!mBaseType.IsAssignableFrom(lType)) { continue; } string lFriendlyName = BaseNameAttribute.GetName(lType); if (mSearchString.Length > 0) { if (lFriendlyName.IndexOf(mSearchString) < 0) { if (lType.Name.IndexOf(mSearchString) < 0) { continue; } } } string lDescription = BaseDescriptionAttribute.GetDescription(lType); mTypes.Add(lType); mNames.Add(lFriendlyName); mDescriptions.Add(lDescription); } }