public void SaveFile(InputField inputField) { var thisFilename = inputField.text; if (thisFilename != "") { thisFilename = Path.GetFileNameWithoutExtension(thisFilename.Replace(" ", "")); Debug.Log("Saved File with filename " + thisFilename); Avatar.saveFilename = thisFilename; DynamicCharacterAvatar.SaveOptions thisSaveOptions = DynamicCharacterAvatar.SaveOptions.useDefaults; if (_saveDNA || _saveWardrobe || _saveColors) { if (_saveDNA) { thisSaveOptions |= DynamicCharacterAvatar.SaveOptions.saveDNA; } if (_saveWardrobe) { thisSaveOptions |= DynamicCharacterAvatar.SaveOptions.saveWardrobe; } if (_saveColors) { thisSaveOptions |= DynamicCharacterAvatar.SaveOptions.saveColors; } thisSaveOptions &= ~DynamicCharacterAvatar.SaveOptions.useDefaults; } Avatar.DoSave(false, "", thisSaveOptions); } StartCoroutine(FinishSaveFile()); }
/// <summary> /// Use this model for saving a DCS Avatar to a light weight json string. Use the save options flags to determine what aspects of the avatar are saved /// </summary> /// <param name="dcaToSave"></param> /// <param name="recipeName"></param> /// <param name="recipeType"></param> /// <param name="saveOptions"></param> /// <param name="slotsToSave"></param> public DCSPackRecipe(DynamicCharacterAvatar dcaToSave, string recipeName, string pRecipeType, DynamicCharacterAvatar.SaveOptions saveOptions, params string[] slotsToSave) { if (pRecipeType != "DynamicCharacterAvatar") { Debug.LogWarning("DCSPackRecipe Type can only be used for recipeTypes 'DynamicCharacterAvatar'"); return; } var recipeToSave = dcaToSave.umaData.umaRecipe; packedRecipeType = pRecipeType; name = recipeName; race = dcaToSave.activeRace.racedata.raceName; if (saveOptions.HasFlag(DynamicCharacterAvatar.SaveOptions.saveDNA)) { dna = GetPackedDNA(recipeToSave); } if (saveOptions.HasFlag(DynamicCharacterAvatar.SaveOptions.saveColors)) { characterColors = new List <PackedOverlayColorDataV3>(); for (int i = 0; i < recipeToSave.sharedColors.Length; i++) { characterColors.Add(new PackedOverlayColorDataV3(recipeToSave.sharedColors[i])); } } if (saveOptions.HasFlag(DynamicCharacterAvatar.SaveOptions.saveWardrobe)) { wardrobeSet = GenerateWardrobeSet(dcaToSave.WardrobeRecipes, slotsToSave); } if (saveOptions.HasFlag(DynamicCharacterAvatar.SaveOptions.saveAnimator)) { if (dcaToSave.animationController != null) { raceAnimatorController = (dcaToSave.animationController.name); } } }
//This is the save method used by DCA.DoSave and the 'optimized' UMA Menu save options /// <summary> /// Save the DynamicCharacterAvatar using the optimized DCSPackRecipe model (Not compatible with non-DynamicCharacterAvatars) /// </summary> /// <param name="dcaToSave"></param> /// <param name="recipeName"></param> /// <param name="saveOptions">Set the save flags options to choose which properties of the Avatar to save</param> public void SaveDCS(DynamicCharacterAvatar dcaToSave, string recipeName, DynamicCharacterAvatar.SaveOptions saveOptions) { recipeString = JsonUtility.ToJson(new DCSPackRecipe(dcaToSave, recipeName, "DynamicCharacterAvatar", saveOptions)); }
public UMADynamicCharacterAvatarRecipe(DynamicCharacterAvatar dca, string recipeName = "", DynamicCharacterAvatar.SaveOptions customSaveOptions = DynamicCharacterAvatar.SaveOptions.useDefaults) { recipeType = "DynamicCharacterAvatar"; if (customSaveOptions.HasFlagSet(DynamicCharacterAvatar.SaveOptions.useDefaults)) { customSaveOptions = dca.defaultSaveOptions; } if (recipeName == "") { recipeName = dca.gameObject.name; } recipeString = JsonUtility.ToJson(new DCSPackRecipe(dca, recipeName, "DynamicCharacterAvatar", customSaveOptions)); }