public static void LoadSelectedAvatarsTxt() { for (int i = 0; i < Selection.gameObjects.Length; i++) { var selectedTransform = Selection.gameObjects[i].transform; var avatar = selectedTransform.GetComponent <UMAAvatarBase>(); while (avatar == null && selectedTransform.parent != null) { selectedTransform = selectedTransform.parent; avatar = selectedTransform.GetComponent <UMAAvatarBase>(); } if (avatar != null) { var path = EditorUtility.OpenFilePanel("Load serialized Avatar", "Assets", "txt"); if (path.Length != 0) { var asset = ScriptableObject.CreateInstance <UMATextRecipe>(); asset.recipeString = UMAFileUtils.ReadAllText(path); avatar.Load(asset); Destroy(asset); } } } }
static void CreateDNAHelperCode() { var destDir = Path.Combine(Directory.GetCurrentDirectory(), "Assets/Character/UMA/UMA_Generated/DnaHelpers"); var sourceDir = Path.Combine(Directory.GetCurrentDirectory(), "Assets/Character/UMA/Editor/Templates"); var baseTemplate = UMAFileUtils.ReadAllText(Path.Combine(sourceDir, "UmaDna_Template.cs.txt")); var pageTemplate = UMAFileUtils.ReadAllText(Path.Combine(sourceDir, "UmaDnaChild_Template.cs.txt")); var templates = CodeGenTemplate.ParseTemplates(sourceDir, baseTemplate); var pageTemplates = CodeGenTemplate.ParseTemplates(sourceDir, pageTemplate); customFormatter = new DictionaryCustomFormatter(); CodeGenTemplate.formatter = customFormatter; var baseDnaType = typeof(UMADnaBase); var customData = new Dictionary <string, object>(); customData.Add("ClassName", ""); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { foreach (var dnaType in assembly.GetTypes()) { if (DerivesFrom(dnaType, baseDnaType)) { if (dnaType.Name == "UMADna") { continue; } customData["ClassName"] = dnaType.Name; foreach (var template in pageTemplates) { template.sb.Length = 0; } foreach (var template in templates) { template.Append(customData); } CreateDNAHelperCode(dnaType, destDir, pageTemplate, pageTemplates); } } } foreach (var template in templates) { customData.Add(template.Name, template.sb); } CreateBaseDNAExtension(destDir, baseTemplate, customData); AssetDatabase.Refresh(); }