/// <summary> /// Similar to the wizard parameterless version, but this wizard /// can work in one of two ways: /// /// editTarget == null: A new variable type will be created /// editTarget != null: An old variable type will be overridden. /// /// Unless the goal is to pass in non-null editTarget, call this /// without parameters. /// </summary> /// <param name="editTarget"> /// Script set to override, if not null. /// </param> public static void CreateWizard(ScriptSetInfo editTarget) { NewVariableTypeWizard wizard = DisplayWizard <NewVariableTypeWizard>( "Create Variable Object Type", "Create" ); if (editTarget != null) { wizard.humanReadableName = editTarget.Name; wizard.dataType = editTarget.TypeName; wizard.referability = editTarget.Referability; wizard.menuOrder = editTarget.MetaData.menuOrder; wizard.builtin = editTarget.MetaData.builtin; wizard.targetFolder = new UnityFolderPath(editTarget.DominantPath); } else { wizard.humanReadableName = ""; wizard.dataType = ""; wizard.referability = ReferabilityMode.Unknown; wizard.menuOrder = 350000; wizard.builtin = false; wizard.targetFolder = new UnityFolderPath(EditorPrefs.GetString(PathPref)); } wizard.editTarget = editTarget; // Force a update...it's possible that, with the parameters we've // passed in, it's valid. Otherwise, it won't detect that it's valid // until the user changes ones of the fields. wizard.OnWizardUpdate(); }
public static void ReopenWizard(NewVariableTypeWizard oldWizard) { NewVariableTypeWizard wizard = DisplayWizard <NewVariableTypeWizard>( "Create Variable Object Type", "Create" ); wizard.humanReadableName = oldWizard.humanReadableName; wizard.dataType = oldWizard.dataType; wizard.referability = oldWizard.referability; wizard.menuOrder = oldWizard.menuOrder; wizard.targetFolder = oldWizard.targetFolder; wizard.editTarget = oldWizard.editTarget; wizard.builtin = oldWizard.builtin; wizard.OnWizardUpdate(); }
public static void CreateWizard( string initName, string initType, ReferabilityMode initMode, string initPath ) { NewVariableTypeWizard wizard = ScriptableWizard.DisplayWizard <NewVariableTypeWizard>( "Create Variable Object Type", "Create" ); wizard.humanReadableName = initName; wizard.dataType = initType; wizard.referability = initMode; wizard.targetFolder = new UnityFolderPath(initPath); // Force a update...it's possible that, with the parameters we've // passed in, it's valid. Otherwise, it won't detect that it's valid // until the user changes ones of the fields. wizard.OnWizardUpdate(); }
private void DrawVarObjHierarchy( string masterLabel, string masterFoldoutPref, Dictionary <string, ScriptSetInfo> fileInfoDictionary, bool canEdit ) { bool isFoldedOut; // A catch-all variable for storing the foldout bools // Create the main foldout isFoldedOut = EditorPrefs.GetBool(masterFoldoutPref, defaultValue: false); isFoldedOut = EditorGUILayout.Foldout(isFoldedOut, masterLabel, toggleOnLabelClick: true); EditorPrefs.SetBool(masterFoldoutPref, isFoldedOut); // Only render the list itself if it's folded out. if (isFoldedOut) { EditorGUI.indentLevel++; // Step through all of the types found foreach (ScriptSetInfo fileInfo in fileInfoDictionary.Values) { // Draw the foldout (with its buttons, if folded out and editable). // We need to figure out if we're folded out, according to the preferences. string editorPrefKey = EditorPrefPrefix + fileInfo.Name; bool isTypeFoldedOut = EditorPrefs.GetBool(editorPrefKey, defaultValue: false); // We want a compact label if folded out. Otherwise, we'll list more info. string foldoutLabel = fileInfo.Name; if (!isTypeFoldedOut) { foldoutLabel += (" (" + fileInfo.TypeName + ", " + fileInfo.Referability.ToString() + ") "); } FoldoutEventInfo foldoutInfo = DrawFoldout( EditorPrefs.GetBool(editorPrefKey, defaultValue: false), foldoutLabel, canEdit ); EditorPrefs.SetBool(editorPrefKey, foldoutInfo.isFoldedOut); // Again, only render the list of files if the foldout is open. if (foldoutInfo.isFoldedOut) { EditorGUI.indentLevel++; DrawFiles(fileInfo.GUIDs); EditorGUI.indentLevel--; } // Handle stuff with the delete button if (foldoutInfo.selectedDelete) { //Debug.Log("Delete " + fileInfo.name); //DeleteFilesForType(fileInfo); //ScriptFileManager.DeleteFilesForType(fileInfo, prompt: true); bool deletionConfirmed = EditorUtility.DisplayDialog( "Delete variable object scripts named '" + fileInfo.Name + "'?", "This action cannot be undone!" + "\n(Check Variable Object Settings for list of files.)", "Delete them", "Spare them" ); if (deletionConfirmed) { fileInfo.DeleteFiles(); } } else if (foldoutInfo.selectedEdit) { NewVariableTypeWizard.CreateWizard(fileInfo); } else if (foldoutInfo.selectedRemake) { bool remakeConfirmed = EditorUtility.DisplayDialog( "Remake variable object scripts named '" + fileInfo.Name + "'?", "They will be placed inside " + fileInfo.DominantPath + "\n" + "This action cannot be undone!\n" + "(Check Variable Object Settings for list of files.)", "Remake them", "Maybe not" ); if (remakeConfirmed) { List <string> modifiedFiles = fileInfo.RebuildFiles(); } } } // End foreach(...fileInfo...) if (GUILayout.Button("Rebuild all")) { bool remakeConfirmed = EditorUtility.DisplayDialog( "Remake all " + masterLabel, "Remake ALL of the scripts? This could break things if you aren't careful!", "Remake them all!", "Hang on!" ); if (remakeConfirmed) { foreach (ScriptSetInfo setInfo in fileInfoDictionary.Values) { setInfo.RebuildFiles(); } } } EditorGUI.indentLevel--; } // End if(isFoldedOut) } // End DrawVarObjHierarchy