//This is used when an inspected recipe asset is saved public override void Save(UMAData.UMARecipe umaRecipe, UMAContext context) { if (recipeType == "Wardrobe") //Wardrobe Recipes can save the standard UMA way- they dont have WardrobeSets- although the recipe string wont have a packedRecipeType field { base.Save(umaRecipe, context); } else if (recipeType != "Standard") //this will just be for type DynamicCharacterAvatar- and WardrobeCollection if we add that { var packedRecipe = PackRecipeV2(umaRecipe); //DCSPackRecipe doesn't do any more work, it just gets the values from PackRecipeV2 that we need and discards the rest var packedRecipeToSave = new DCSPackRecipe(packedRecipe, this.name, recipeType, activeWardrobeSet); recipeString = JsonUtility.ToJson(packedRecipeToSave); } else //This will be Standard- this is 'backwards Compatible' and is also how the Recipe Editor saves 'backwardsCompatible' 'Standard' recipes when they are inspected { umaRecipe.MergeMatchingOverlays(); var packedRecipe = PackRecipeV2(umaRecipe); var packedRecipeToSave = new DCSUniversalPackRecipe(packedRecipe); //this gets us a recipe with all the standard stuff plus our extra fields //so now we can save the wardrobeSet into it if it existed if (activeWardrobeSet != null) { if (activeWardrobeSet.Count > 0) { packedRecipeToSave.wardrobeSet = activeWardrobeSet; } } recipeString = JsonUtility.ToJson(packedRecipeToSave); } }
/// <summary> /// Returns the recipe string as a DCSUniversalPackRecipe data model that can be used by any UMA /// </summary> /// <param name="context"></param> /// <param name="recipeToUnpack"></param> /// <param name="targetUTR">If set the wardrobeSet (if it exists) and the recipeType will assigned to UMATextRecipe assets fields (used by the Recipe Editor)</param> /// <returns></returns> public static DCSUniversalPackRecipe PackedLoadDCS(UMAContext context, string recipeToUnpack, UMATextRecipe targetUTR = null) { if ((recipeToUnpack == null) || (recipeToUnpack.Length == 0)) { return(new DCSUniversalPackRecipe()); } //first use the DCSRecipeChecker to check if this is a DCS recipe var typeInRecipe = GetRecipesType(recipeToUnpack); var targetRecipeType = typeInRecipe != "Standard" ? typeInRecipe : (targetUTR != null ? targetUTR.recipeType : "Standard"); if (targetUTR != null) { targetUTR.recipeType = targetRecipeType; if (RecipeHasWardrobeSet(recipeToUnpack)) { targetUTR.activeWardrobeSet = GetRecipesWardrobeSet(recipeToUnpack); } } //Right now the only recipeType that uses the DCSModel is "DynamicCharacterAvatar" DCSUniversalPackRecipe thisUnpackedUniversal = null; if (targetRecipeType == "DynamicCharacterAvatar" || targetRecipeType == "WardrobeCollection") { var thisUnpacked = JsonUtility.FromJson <DCSPackRecipe>(recipeToUnpack); thisUnpackedUniversal = new DCSUniversalPackRecipe(thisUnpacked); } else { var thisUnpacked = JsonUtility.FromJson <UMAPackRecipe>(recipeToUnpack); thisUnpackedUniversal = new DCSUniversalPackRecipe(thisUnpacked); } if (RecipeHasWardrobeSet(recipeToUnpack)) { thisUnpackedUniversal.wardrobeSet = GetRecipesWardrobeSet(recipeToUnpack); } return(thisUnpackedUniversal); }