public DynamicUMADnaAsset CreateDNAAsset(string assetFolder = "", string assetName = "") { if (assetFolder == "") { assetFolder = AssetDatabase.GetAssetPath(selectedConverter); assetFolder = assetFolder.Substring(0, assetFolder.LastIndexOf('/')); } if (assetName == "") { assetName = selectedConverter.name + "DNAAsset"; var uniquePath = AssetDatabase.GenerateUniqueAssetPath(assetFolder + "/" + assetName + ".asset"); assetName = uniquePath.Replace(assetFolder + "/", "").Replace(".asset", ""); } if (!System.IO.Directory.Exists(assetFolder)) { System.IO.Directory.CreateDirectory(assetFolder); } DynamicUMADnaAsset asset = ScriptableObject.CreateInstance <DynamicUMADnaAsset>(); AssetDatabase.CreateAsset(asset, assetFolder + "/" + assetName + ".asset"); AssetDatabase.SaveAssets(); return(asset); }
public static void DefineDynamicDNAType(DynamicUMADnaAsset asset) { InitializeDynamicDNADictionary(); if (DynamicDNADictionary.ContainsKey(asset.name)) { Debug.LogWarning("DynamicDNADictionary already contained DNA asset " + asset.name); } else { DynamicDNADictionary.Add(asset.name, asset); } }
private void CreatePoseSet(string fileName) { SlotDataAsset sda = CustomAssetUtility.CreateAsset <SlotDataAsset>("", false, fileName + "_Slot", false); sda.slotName = sda.name; sda.nameHash = UMAUtils.StringToHash(sda.slotName); DynamicDNAConverterController ddcc = UMA.CustomAssetUtility.CreateAsset <DynamicDNAConverterController>("", false, fileName + "_Controller", false); sda.slotDNA = ddcc; DynamicUMADnaAsset duda = UMA.CustomAssetUtility.CreateAsset <DynamicUMADnaAsset>("", false, fileName + "_DNAAsset", false); ddcc.DNAAsset = duda; UMABonePose bp = UMA.CustomAssetUtility.CreateAsset <UMABonePose>("", true, fileName + "_Pose", false); BonePoseDNAConverterPlugin bpdcp = (BonePoseDNAConverterPlugin)ddcc.AddPlugin(typeof(BonePoseDNAConverterPlugin)); bpdcp.poseDNAConverters.Add(new BonePoseDNAConverterPlugin.BonePoseDNAConverter()); bpdcp.poseDNAConverters[0].poseToApply = bp; bpdcp.poseDNAConverters[0].startingPoseWeight = 1.0f; EditorUtility.SetDirty(sda); EditorUtility.SetDirty(ddcc); EditorUtility.SetDirty(duda); EditorUtility.SetDirty(bp); EditorUtility.SetDirty(bpdcp); if (addToLibrary) { UMAAssetIndexer.Instance.EvilAddAsset(typeof(SlotDataAsset), sda); UMAAssetIndexer.Instance.EvilAddAsset(typeof(DynamicUMADnaAsset), duda); EditorUtility.SetDirty(UMAAssetIndexer.Instance); } if (createWardrobeRecipe) { string path = CustomAssetUtility.GetAssetPathAndName <UMAWardrobeRecipe>(fileName, false); UMAWardrobeRecipe uwr = UMAEditorUtilities.CreateRecipe(path, sda, null, fileName, addToLibrary); uwr.compatibleRaces = new List <string>(); uwr.wardrobeSlot = "Physique"; uwr.compatibleRaces.Add(raceNames[selectedRace]); EditorUtility.SetDirty(uwr); } AssetDatabase.SaveAssets(); }
/// <summary> /// Method for finding a DynamicUMADnaAsset by name. /// This can happen when a recipe tries to load load an asset based on an instance ID that may have changed or if the Asset is in an AssetBundle and was not available when the dna was loaded /// </summary> /// <param name="dnaAssetName"></param> public virtual void FindMissingDnaAsset(string dnaAssetName) { _dnaAsset = UMAContext.Instance.GetDNA(dnaAssetName); if (_dnaAsset == null) { if (Debug.isDebugBuild) { Debug.LogWarning("DynamicUMADnaBase could not find DNAAsset " + dnaAssetName + "!"); } } /* * InitializeDynamicDNADictionary(); * * if (!DynamicDNADictionary.TryGetValue(dnaAssetName, out _dnaAsset)) * { * if (Debug.isDebugBuild) * Debug.LogWarning("DynamicUMADnaBase could not find DNAAsset " + dnaAssetName + "!"); * } */ }
public void ImportConverterBehaviourData(DynamicDNAConverterBehaviour DCB) { _dnaAsset = DCB.dnaAsset; _overallModifiers.ImportSettings(DCB.overallModifiers); }