protected virtual bool TextRecipeGUI() { Type TargetType = target.GetType(); bool doUpdate = false; EditorGUI.BeginDisabledGroup(true); EditorGUILayout.Popup("Recipe Type", 0, new string[] { "DynamicCharacterAvatar" }); EditorGUI.EndDisabledGroup(); PreRecipeGUI(ref doUpdate); //draws a button to 'Add DNA' when a new 'standard' recipe is created if (AddDNAButtonUI()) { hideToolBar = false; return(true); } //fixes dna when the recipes race has updated from UMADnaHumanoid/Tutorial to DynamicDna if (FixDNAConverters()) { hideToolBar = false; return(true); } FieldInfo ActiveWardrobeSetField = TargetType.GetField("activeWardrobeSet", BindingFlags.Public | BindingFlags.Instance); List <WardrobeSettings> activeWardrobeSet = (List <WardrobeSettings>)ActiveWardrobeSetField.GetValue(target); slotEditor = new WardrobeSetMasterEditor(_recipe, activeWardrobeSet); return(doUpdate); }
private bool TextRecipeGUI() { Type TargetType = target.GetType();//used to get the UMATextRecipe type taher than UMARecipeBase bool doUpdate = false; if (TargetType.ToString() == "UMA.UMATextRecipe") { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.Popup("Recipe Type", 0, new string[] { "Standard" });//other types (WardrobeRecipe, DynamicCharacterAvatarRecipe) have their own editors now so this is just for UI consistancy EditorGUI.EndDisabledGroup(); if (ActiveWardrobeSetField == null) ActiveWardrobeSetField = TargetType.GetField("activeWardrobeSet", BindingFlags.Public | BindingFlags.Instance); activeWardrobeSet = (List<WardrobeSettings>)ActiveWardrobeSetField.GetValue(target); //draws a button to 'Add DNA' when a new 'standard' recipe is created if (AddDNAButtonUI()) { hideToolBar = false; return true; } //fixes dna when the recipes race has updated from UMADnaHumanoid/Tutorial to DynamicDna if (FixDNAConverters()) { hideToolBar = false; return true; } //When recipes are saved from a DynamicCharacterAvatar as a 'Standard' rather than 'Optimized' recipe they are saved as 'BackwardsCompatible' //This means they have slots/overlay data AND a wardrobeSet. In this case we need to draw the "DynamicCharacterAvatarRecipe' slot editor //and this will show an editable Wardrobe set which will update and a slot/overlay list if ((activeWardrobeSet.Count > 0)) { hideRaceField = false; slotEditor = new WardrobeSetMasterEditor(_recipe, activeWardrobeSet); } } return doUpdate; }
private bool TextRecipeGUI() { Type TargetType = target.GetType(); bool doUpdate = false; if (TargetType.ToString() == "UMATextRecipe" /*|| TargetType.ToString() == "UMAWardrobeRecipe" || TargetType.ToString() == "UMADCSRecipe"*/) { FieldInfo RecipeTypeField = TargetType.GetField("recipeType", BindingFlags.Public | BindingFlags.Instance); //the Recipe Type field defines whether the extra wardrobe recipe fields show and whether we are overriding the SlotMasterEditor with WardrobeSetMasterEditor string recipeType = (string)RecipeTypeField.GetValue(target); FieldInfo ActiveWardrobeSetField = TargetType.GetField("activeWardrobeSet", BindingFlags.Public | BindingFlags.Instance); List <WardrobeSettings> activeWardrobeSet = (List <WardrobeSettings>)ActiveWardrobeSetField.GetValue(target); //if this recipeType == Wardrobe the recipe is old, i.e. from before they were seperate type, so show a warning if (recipeType == "WardrobeCollection" || recipeType == "DynamicCharacterAvatar" || recipeType == "Wardrobe") { EditorGUILayout.HelpBox("This is an out of date " + recipeType + " recipe. Please recreate it by creating a new one from the 'Create/UMA/DCS' menu", MessageType.Warning); hideRaceField = true; hideToolBar = true; } EditorGUI.BeginDisabledGroup(true); if (!recipeTypeOpts.Contains(recipeType)) { recipeTypeOpts.Add(recipeType); } int rtIndex = recipeTypeOpts.IndexOf(recipeType); EditorGUILayout.Popup("Recipe Type", rtIndex, recipeTypeOpts.ToArray()); EditorGUI.EndDisabledGroup(); //If this is a Standard recipe or a DynamicCharacterAvatar we may need to fix or update the DNA converters //This happens when the race the recipe uses has a DNA converter that has been changed from UMADNAHumanoid to DynamicDNA if (recipeType == "Standard" || recipeType == "DynamicCharacterAvatar") { //draws a button to 'Add DNA' when a new 'standard' recipe is created if (AddDNAButtonUI()) { hideToolBar = false; return(true); } //fixes dna when the recipes race has updated from UMADnaHumanoid/Tutorial to DynamicDna if (FixDNAConverters()) { hideToolBar = false; return(true); } } //When recipes are saved from a DynamicCharacterAvatar as a 'Standard' rather than 'Optimized' recipe they are saved as 'BackwardsCompatible' //This means they have slots/overlay data AND a wardrobeSet. In this case we need to draw the "DynamicCharacterAvatarRecipe' slot editor //and this will show an editable Wardrobe set which will update an (uneditable) slot/overlay list if ((activeWardrobeSet.Count > 0)) { hideRaceField = false; slotEditor = new WardrobeSetMasterEditor(_recipe, activeWardrobeSet); } } return(doUpdate); }
private bool TextRecipeGUI() { Type TargetType = target.GetType(); bool doUpdate = false; if (TargetType.ToString() == "UMATextRecipe" /*|| TargetType.ToString() == "UMAWardrobeRecipe" || TargetType.ToString() == "UMADCSRecipe"*/) { FieldInfo RecipeTypeField = TargetType.GetField("recipeType", BindingFlags.Public | BindingFlags.Instance); //the Recipe Type field defines whether the extra wardrobe recipe fields show and whether we are overriding the SlotMasterEditor with WardrobeSetMasterEditor string recipeType = (string)RecipeTypeField.GetValue(target); FieldInfo ActiveWardrobeSetField = TargetType.GetField("activeWardrobeSet", BindingFlags.Public | BindingFlags.Instance); List <WardrobeSettings> activeWardrobeSet = (List <WardrobeSettings>)ActiveWardrobeSetField.GetValue(target); //if this recipeType == WardrobeCollection or DynamicCharacterAvatar or Wardrobe show a 'ConvertRecipe' button if (recipeType == "WardrobeCollection" || recipeType == "DynamicCharacterAvatar" || recipeType == "Wardrobe") { //we want this button to convert the UMATextRecipe to the type it should be //and then for the resulting asset to be inspected MethodInfo ConvertMethod = TargetType.GetMethod("ConvertToType"); string typeToConvertTo = ""; if (recipeType == "WardrobeCollection") { typeToConvertTo = "UMAWardrobeCollection"; } else if (recipeType == "DynamicCharacterAvatar") { typeToConvertTo = "UMADynamicCharacterAvatarRecipe"; } else if (recipeType == "Wardrobe") { typeToConvertTo = "UMAWardrobeRecipe"; } //I know this is messy but we can get rid of all of this in the actual release since people wont have made stuff that is wrong if (ConvertMethod != null && typeToConvertTo != "") { EditorGUILayout.HelpBox("Please convert this recipe", MessageType.Warning); if (GUILayout.Button("Convert")) { ConvertMethod.Invoke(target, new object[] { typeToConvertTo }); } } } //Draw the recipe type dropdown for the time being but disable it for types that cant be changed //if people have run the converter from the nagger stop them making UMATextRecipes that are WardrobeRecipes if (recipeType == "DynamicCharacterAvatar" || (EditorPrefs.GetBool(Application.dataPath + ":UMADCARecipesUpToDate") && EditorPrefs.GetBool(Application.dataPath + ":UMAWardrobeRecipesUpToDate"))) { EditorGUI.BeginDisabledGroup(true); } if (!recipeTypeOpts.Contains(recipeType)) { recipeTypeOpts.Add(recipeType); } int rtIndex = recipeTypeOpts.IndexOf(recipeType); int newrtIndex = EditorGUILayout.Popup("Recipe Type", rtIndex, recipeTypeOpts.ToArray()); if (newrtIndex != rtIndex) { RecipeTypeField.SetValue(target, recipeTypeOpts[newrtIndex]); doUpdate = true; } if (recipeType == "DynamicCharacterAvatar" || (EditorPrefs.GetBool(Application.dataPath + ":UMADCARecipesUpToDate") && EditorPrefs.GetBool(Application.dataPath + ":UMAWardrobeRecipesUpToDate"))) { EditorGUI.EndDisabledGroup(); } //If this is a Standard recipe or a DynamicCharacterAvatar we may need to fix or update the DNA converters //This happens when the race the recipe uses has a DNA converter that has been changed from UMADNAHumanoid to DynamicDNA if (recipeType == "Standard" || recipeType == "DynamicCharacterAvatar") { //draws a button to 'Add DNA' when a new 'standard' recipe is created if (AddDNAButtonUI()) { hideToolBar = false; return(true); } //fixes dna when the recipes race has updated from UMADnaHumanoid/Tutorial to DynamicDna if (FixDNAConverters()) { hideToolBar = false; return(true); } } //When recipes are saved from a DynamicCharacterAvatar as a 'Standard' rather than 'Optimized' recipe they are saved as 'BackwardsCompatible' //This means they have slots/overlay data AND a wardrobeSet. In this case we need to draw the "DynamicCharacterAvatarRecipe' slot editor //and this will show an editable Wardrobe set which will update an (uneditable) slot/overlay list if ((activeWardrobeSet.Count > 0)) { hideRaceField = false; slotEditor = new WardrobeSetMasterEditor(_recipe, activeWardrobeSet); } //else if its a wardrobe recipe override the slot editor else if (recipeType == "Wardrobe") { hideRaceField = true; hideToolBar = true; //CompatibleRaces drop area if (DrawCompatibleRacesUI(TargetType)) { doUpdate = true; } //Wardrobe slots dropdowns if (DrawWardrobeSlotsFields(TargetType)) { doUpdate = true; } //assign the slotEditor after the others so we have the SlotOptions created slotEditor = new WardrobeRecipeMasterEditor(_recipe, generatedBaseSlotOptions, generatedBaseSlotOptionsLabels); EditorGUILayout.Space(); } } return(doUpdate); }