/// <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(); }
/// <summary> /// Builds the type info, based on all of the files that match the given /// label. The keys are the human-readable names, NOT the type-names /// which the objects might handle. /// </summary> /// <returns> /// The type info dictionary, with the human-readable /// type names being the keys. /// </returns> /// <param name="label">Label which to search for.</param> private static Dictionary <string, ScriptSetInfo> BuildTypeInfo(string label) { Dictionary <string, ScriptSetInfo> allTypeInfo = new Dictionary <string, ScriptSetInfo>(); string[] allGuids = AssetDatabase.FindAssets("l:" + label); foreach (string guid in allGuids) { // Used for tracking stuff we read from this specific file. ScriptMetaData fileData = ExtractDataFromFile( AssetDatabase.GUIDToAssetPath(guid) ); // We need to see if we already know about a variable object // which uses this name. If not, we'll build a new typeInfo // object. At the end of all of this, we save the GUID of // the file into the typeInfo object. ScriptSetInfo typeInfo; if (!allTypeInfo.TryGetValue(fileData.name, out typeInfo)) { // First file of this typeName, so allTypeInfo doesn't // contain any info on it. typeInfo = new ScriptSetInfo(fileData); allTypeInfo[typeInfo.Name] = typeInfo; if (fileData.ParsedReferability == ReferabilityMode.Unknown) { Debug.LogWarning( "Unable to identify the referability mode for " + AssetDatabase.GUIDToAssetPath(guid) ); } } // End if(!allTypeInfo.TryGetValue(typeName, out typeInfo)) else { // Only need to do these checks if there was another // object which claimed this name. So there's a chance // we'll see a mismatch in something. if (typeInfo.MetaData != fileData) { Debug.LogWarning( "Metadata mismatch in " + AssetDatabase.GUIDToAssetPath(guid) + '\n' + "Expected:\n" + typeInfo.MetaData + '\n' + "But Found:\n" + fileData ); } } // End if(!allTypeInfo.TryGetValue(typeName, out typeInfo)) // Now we can FINALLY track this file. typeInfo.AddGUID(guid); } // End foreach(string guid in allGuids) return(allTypeInfo); }