using System; using UnityEngine; using System.Collections.Generic; using MVR.FileManagementSecure; using System.Linq; using SimpleJSON; using System.Collections; namespace ky1001 { public class AppearanceLoader : MVRScript { #region PluginInfo public string pluginAuthor = "ky1001"; public string pluginName = "AppearanceLoader"; public string pluginVersion = "13.2"; public string pluginDate = "2024-08-18"; public string pluginDescription = "wait test"; #endregion #region Vars private const string _vapLookPath = "Custom\\Atom\\Person\\Appearance"; private const string _jsonLookPath = "Saves\\Person\\appearance"; private const string _jsonScenePath = "Saves\\scene"; private string LoadData; private string ext; private string reload; private string loadDir; private string vapPreviousFolder; private string jsonPreviousFolder; private string scenePreviousFolder; private string SELF; Vector3 rootPosi; Vector3 rootRota; private Vector3 localPosi; private Vector3 localRota; private Vector3 posi; private Vector3 rota; private Vector3 targetPosi; private Vector3 targetRota; private Vector3 tempPosi; private Vector3 tempRota; protected JSONStorableStringChooser selectPerson; private JSONStorableBool shortcuts_Bool; private UIDynamicToggle shortcuts_toggle; private JSONStorableBool morphs_Bool; private JSONStorableBool textures_Bool; private JSONStorableBool eye_Bool; private JSONStorableBool mouth_Bool; private JSONStorableBool hair_Bool; private JSONStorableBool clothing_Bool; private JSONStorableBool clothingMerge_Bool; private JSONStorableBool keepFolder_Bool; private JSONStorableBool cua_Bool; private JSONStorableBool scale_Bool; private JSONStorableBool breast_Bool; private JSONStorableBool glute_Bool; private JSONStorableBool deletePluginPreset_Bool; private JSONStorableBool plugin_Bool; private JSONStorableString filename; private UIDynamicTextField messageBox; private UIDynamicTextField messageBox2; private UIDynamicTextField messageBox3; private UIDynamicTextField messageBox4; private JSONStorableString message; private JSONStorableString missingItem; private JSONStorableString persons; private JSONStorableString hairAndClothing; private List personList = new List(); private JSONNode jSONNode; private JSONArray atomArray; private JSONArray asArray; private JSONArray morphsAsArray; private JSONArray hairAsArray; private JSONArray clothingAsArray; private JSONClass cuaPluginPreset; private JSONClass pluginPreset; private JSONClass asAtomObject; private JSONClass asObject; private JSONClass hairAsObject; private JSONClass clothingAsObject; private JSONClass morphs; private Dictionary asObjectCUA = new Dictionary(); protected Atom TargetAtom; private string id; private string characterName; private float scale; private bool sceneBool; private bool reloadBool; private string tempHair; private string tempClothing; private string emptyName; private bool femeleOnMale; private bool maleOnFemale; private Dictionary> idDic = new Dictionary>(); private Dictionary simClothingDic = new Dictionary(); private Dictionary sourcePositionDic = new Dictionary(); private Dictionary sourceRotationDic = new Dictionary(); private List simClothingList = new List(); private List idListVap = new List(); private List hairList = new List(); private List clothingList = new List(); Dictionary PosiST = new Dictionary(); Dictionary RotaST = new Dictionary(); Rigidbody linkToAtom; private Rigidbody _rigid; JSONStorable geometry; DAZCharacterSelector character; GenerateDAZMorphsControlUI morphControl; Dictionary paramControls = new Dictionary(); private bool _isReset; private readonly string[] idList = new string[] { "BreastControl", "GluteControl", "LowerPhysicsMesh", "BreastPhysicsMesh", "JawControl", "FemaleEyelashes", "MaleEyelashes", "irises", "sclera", "lacrimals", "skin", "textures", "teeth", "tongue", "mouth" }; private readonly string[] idList2 = new string[] { "rescaleObject", "BendFix", "FemaleAnatomy", "BreastInOut", "EyelidControl", "AutoJawMouthMorph", "AutoExpressions", "SoftBodyPhysicsEnabler" }; private readonly string[] idList3 = new string[] { "AllJointsControl", "AnimatedFingerDrive", "AppearancePresets", "AtomControl", "CharacterPoseSnapRestore", "DebugJointsControl", "Eyes", "FemaleAnatomyAlt", "FemaleBreastPhysicsPresets", "FemaleGlutePhysicsPresets", "Genesis2Female", "geometry", "HairPresets", "HeadAudioSource", "LeftHandControl", "LeftHandFingerControl", "lEye", "MaleAnatomy", "MorphPresets", "PhysicsModel", "PluginManager", "PluginPresets", "PosePresets", "Preset", "rEye", "RightHandControl", "RightHandFingerControl", "SkinPresets", "SpeechBubble", "ThoughtBubble", "TongueControl", "TriggerGroup", "upperJaw" }; private readonly string[] actionList = new string[] { "SaveToStore1", "SaveToStore2", "SaveToStore3", "RestoreAllFromStore1", "RestorePhysicsFromStore1", "RestoreAppearanceFromStore1", "RestoreAllFromStore2", "RestorePhysicsFromStore2", "RestoreAppearanceFromStore2", "RestoreAllFromStore3", "RestorePhysicsFromStore3", "RestoreAppearanceFromStore3", "RestoreAllFromDefaults", "RestorePhysicalFromDefaults", "RestoreAppearanceFromDefaults", "CreateUVTemplateTexture", "CreateSimTemplateTexture", "OpenTextureFolderInExplorer" }; private readonly string[] rigidbodies = new string[] { "chest", "hip", "head", "neck", "lToe", "lFoot", "lShin", "lThigh", "lHand", "lForeArm", "lShldr", "lCollar", "rToe", "rFoot", "rShin", "rThigh", "rHand", "rForeArm", "rShldr", "rCollar", "abdomen", "abdomen2", "pelvis", "lPectoral", "rPectoral", "LGlute", "RGlute" }; #endregion // Use this for initialization public override void Init() { try { TargetAtom = containingAtom; #region Buttons filename = new JSONStorableString("Set Appearance Filename", "Custom/Atom/Person/Appearance/"); vapPreviousFolder = _vapLookPath; jsonPreviousFolder = _jsonLookPath; scenePreviousFolder = _jsonScenePath; SELF = ""; keepFolder_Bool = new JSONStorableBool("Keep the previous folder", true); CreateToggle(keepFolder_Bool, false); var loadVapLook = CreateButton("Load Vap Appearance Preset", false); loadVapLook.button.onClick.AddListener(() => { var tempPath = _vapLookPath; if (keepFolder_Bool.val) { tempPath = vapPreviousFolder; } filename.val = ""; selectPerson.val = "None"; sceneBool = false; var vapLookShortcuts = FileManagerSecure.GetShortCutsForDirectory(_vapLookPath, false, false, true, true); SuperController.singleton.GetMediaPathDialog(HandleLoadPreset, "vap", tempPath, true, true, false, null, false, vapLookShortcuts); }); JSONStorableAction LoadVapDatas = new JSONStorableAction("Load Appearance from VapPreset", () => { selectPerson.val = "None"; sceneBool = false; HandleLoadPreset(""); }); var loadJsonLook = CreateButton("Load Json Appearance Preset", false); loadJsonLook.button.onClick.AddListener(() => { var tempPath = _jsonLookPath; if (keepFolder_Bool.val) { tempPath = jsonPreviousFolder; } filename.val = ""; selectPerson.val = "None"; sceneBool = false; var jsonLookShortcuts = FileManagerSecure.GetShortCutsForDirectory(_jsonLookPath, false, false, true, true); SuperController.singleton.GetMediaPathDialog(HandleLoadPreset, "json", tempPath, true, true, false, null, false, jsonLookShortcuts); }); JSONStorableAction LoadJsonDatas = new JSONStorableAction("Load Appearance from JsonPreset", () => { selectPerson.val = "None"; sceneBool = false; HandleLoadPreset(""); }); //var spacer = CreateSpacer(false); //spacer.height = 40f; //spacer = CreateSpacer(true); //spacer.height = 40f; var reloadLook = CreateButton("Reload Appearance Preset", true); reloadLook.button.onClick.AddListener(() => { reloadBool = true; HandleLoadPreset(reload); }); reloadLook.buttonColor = Color.yellow; JSONStorableAction reloadAct = new JSONStorableAction("Reload Appearance Preset", () => { reloadBool = true; HandleLoadPreset(reload); }); shortcuts_Bool = new JSONStorableBool("Use Shortcuts in Scene Load Dialog", false); shortcuts_toggle = CreateToggle(shortcuts_Bool, true); var selectScene = CreateButton("Select Scene", true); selectScene.button.onClick.AddListener(() => { var tempPath = _jsonScenePath; if (keepFolder_Bool.val) { tempPath = scenePreviousFolder; } filename.val = ""; selectPerson.val = "None"; sceneBool = true; var jsonSceneShortcuts = FileManagerSecure.GetShortCutsForDirectory(_jsonScenePath, false, false, true, true); if (!shortcuts_Bool.val) { jsonSceneShortcuts = null; } SuperController.singleton.GetMediaPathDialog(HandleLoadPreset, "json", tempPath, true, true, false, null, false, jsonSceneShortcuts); }); JSONStorableAction SelectSceneDatas = new JSONStorableAction("Select Scene", () => { selectPerson.val = "None"; sceneBool = true; HandleLoadPreset(""); }); selectPerson = new JSONStorableStringChooser("Select Person", null, "None", "Select Person"); UIDynamicPopup udp3 = CreatePopup(selectPerson, true); udp3.popup.selectColor = new Color(0.8f, 0.8f, 0.8f); personList.Add("None"); selectPerson.choices = personList; selectPerson.val = "None"; var loadScene = CreateButton("Load Appearance From Scene", true); loadScene.button.onClick.AddListener(() => { if (selectPerson.val == "None") { var tempPath = _jsonScenePath; if (scenePreviousFolder != "" && keepFolder_Bool.val) { tempPath = scenePreviousFolder; } filename.val = ""; sceneBool = true; //var jsonSceneShortcuts = FileManagerSecure.GetShortCutsForDirectory(scenePreviousFolder, false, false, true, true); var jsonSceneShortcuts = FileManagerSecure.GetShortCutsForDirectory(_jsonScenePath, false, false, true, true); if (!shortcuts_Bool.val) { jsonSceneShortcuts = null; } SuperController.singleton.GetMediaPathDialog(HandleLoadPreset, "json", tempPath, true, true, false, null, false, jsonSceneShortcuts); //SuperController.singleton.GetMediaPathDialog(HandleLoadPreset, "json", _jsonScenePath); } else { sceneBool = true; HandleLoadPreset(reload); } }); JSONStorableAction LoadSceneDatas = new JSONStorableAction("Load Appearance From Scene", () => { sceneBool = true; HandleLoadPreset(""); }); //spacer = CreateSpacer(false); //spacer.height = 40f; message = new JSONStorableString("", ""); messageBox = CreateTextField(message, false); messageBox.height = 200f; hairAndClothing = new JSONStorableString("", ""); messageBox2 = CreateTextField(hairAndClothing, false); messageBox2.height = 270f; persons = new JSONStorableString("", ""); messageBox3 = CreateTextField(persons, true); messageBox3.height = 140f; missingItem = new JSONStorableString("", ""); messageBox4 = CreateTextField(missingItem, true); messageBox4.height = 235f; var selectAll = CreateButton("Select All Options"); selectAll.button.onClick.AddListener(SelectAll); JSONStorableAction selectAllAct = new JSONStorableAction("Select All Options", SelectAll); var clearAll = CreateButton("Clear All Options"); clearAll.button.onClick.AddListener(ClearAll); JSONStorableAction clearAllAct = new JSONStorableAction("Clear All Options", ClearAll); morphs_Bool = new JSONStorableBool("Change Morphs", true); CreateToggle(morphs_Bool, false); scale_Bool = new JSONStorableBool("Change Scale", true); CreateToggle(scale_Bool, false); breast_Bool = new JSONStorableBool("Change Breast Physics", true); CreateToggle(breast_Bool, false); glute_Bool = new JSONStorableBool("Change Glute Physics", true); CreateToggle(glute_Bool, false); textures_Bool = new JSONStorableBool("Change Textures", true); CreateToggle(textures_Bool, false); eye_Bool = new JSONStorableBool("Change Eyes", true); CreateToggle(eye_Bool, false); mouth_Bool = new JSONStorableBool("Change Mouth", true); CreateToggle(mouth_Bool, true); hair_Bool = new JSONStorableBool("Change Hair", true); CreateToggle(hair_Bool, true); clothing_Bool = new JSONStorableBool("Change Clothing", true); CreateToggle(clothing_Bool, true); clothingMerge_Bool = new JSONStorableBool("Clothing Merge Load", false); CreateToggle(clothingMerge_Bool, true); cua_Bool = new JSONStorableBool("Load CUA (Scene only)", true); CreateToggle(cua_Bool, true); plugin_Bool = new JSONStorableBool("Load Plugin", false); CreateToggle(plugin_Bool, true); deletePluginPreset_Bool = new JSONStorableBool("Delete Plugin Preset File", true); CreateToggle(deletePluginPreset_Bool, true); PosiST["On"] = FreeControllerV3.PositionState.On; PosiST["Comply"] = FreeControllerV3.PositionState.Comply; PosiST["Off"] = FreeControllerV3.PositionState.Off; PosiST["ParentLink"] = FreeControllerV3.PositionState.ParentLink; PosiST["PhysicsLink"] = FreeControllerV3.PositionState.PhysicsLink; PosiST["Hold"] = FreeControllerV3.PositionState.Hold; PosiST["Lock"] = FreeControllerV3.PositionState.Lock; RotaST["On"] = FreeControllerV3.RotationState.On; RotaST["Comply"] = FreeControllerV3.RotationState.Comply; RotaST["Off"] = FreeControllerV3.RotationState.Off; RotaST["ParentLink"] = FreeControllerV3.RotationState.ParentLink; RotaST["PhysicsLink"] = FreeControllerV3.RotationState.PhysicsLink; RotaST["Hold"] = FreeControllerV3.RotationState.Hold; RotaST["Lock"] = FreeControllerV3.RotationState.Lock; RegisterString(filename); RegisterBool(keepFolder_Bool); RegisterAction(LoadVapDatas); RegisterAction(LoadJsonDatas); RegisterAction(reloadAct); RegisterBool(shortcuts_Bool); RegisterAction(SelectSceneDatas); RegisterStringChooser(selectPerson); RegisterAction(LoadSceneDatas); RegisterBool(morphs_Bool); RegisterBool(scale_Bool); RegisterBool(breast_Bool); RegisterBool(glute_Bool); RegisterBool(textures_Bool); RegisterBool(eye_Bool); RegisterBool(mouth_Bool); RegisterBool(hair_Bool); RegisterBool(clothing_Bool); RegisterBool(clothingMerge_Bool); RegisterBool(cua_Bool); RegisterBool(plugin_Bool); RegisterBool(deletePluginPreset_Bool); RegisterAction(selectAllAct); RegisterAction(clearAllAct); #endregion } catch (Exception e) { SuperController.LogError("Exception caught: " + e); } } private void SelectAll() { morphs_Bool.val = true; scale_Bool.val = true; breast_Bool.val = true; glute_Bool.val = true; textures_Bool.val = true; eye_Bool.val = true; mouth_Bool.val = true; hair_Bool.val = true; clothing_Bool.val = true; clothingMerge_Bool.val = true; cua_Bool.val = true; plugin_Bool.val = true; deletePluginPreset_Bool.val = true; } private void ClearAll() { morphs_Bool.val = false; scale_Bool.val = false; breast_Bool.val = false; glute_Bool.val = false; textures_Bool.val = false; eye_Bool.val = false; mouth_Bool.val = false; hair_Bool.val = false; clothing_Bool.val = false; clothingMerge_Bool.val = false; cua_Bool.val = false; plugin_Bool.val = false; deletePluginPreset_Bool.val = false; } private void makeDic() { idDic = new Dictionary>(); foreach (var item in idList) { if (TargetAtom.GetStorableByID(item) != null) { var act = TargetAtom.GetStorableByID(item).GetActionNames(); var actAndParam = TargetAtom.GetStorableByID(item).GetAllParamAndActionNames(); List param = new List(); foreach (var dummy in actAndParam) { if (!act.Contains(dummy) && !actionList.Contains(dummy)) { param.Add(dummy); } } if (param.Count >= 1) { idDic[item] = param; } } } } #region Preset Load and Save private void HandleLoadPreset(string path) { if (filename.val != "") { filename.val = filename.val.Replace("\\", "/"); if (filename.val.Length > 5) { if (filename.val.Substring(filename.val.Length - 5, 5) == ".json") { ext = ".json"; } } if (filename.val.Length > 4) { if (filename.val.Substring(filename.val.Length - 4, 4) == ".vap") { ext = ".vap"; } } if (ext == "") { filename.val = filename.val + ".vap"; } if (filename.val.IndexOf(":") == -1) { if (filename.val.Substring(0, 7) != "Custom/") { path = "Custom/Atom/Person/Appearance/" + filename.val; } else { path = filename.val; } } else { path = filename.val; } } if (path == "") { return; } else { path = path.Replace("\\", "/"); reload = path; } hairAndClothing.val = ""; if (!sceneBool) { personList = new List(); personList.Clear(); personList.Add("None"); selectPerson.choices = personList; selectPerson.val = "None"; persons.val = ""; var pathSplit = path.Replace("\\", "/").Split('/'); var tempName = pathSplit[pathSplit.Length - 1]; if (tempName.Substring(0, 7) == "Preset_") { tempName = tempName.Substring(7); } tempName = tempName.Replace(".vap", "").Replace(".json", ""); hairAndClothing.val = "Preset Name: " + tempName + "\n"; } else if (selectPerson.val == "None") { personList = new List(); personList.Clear(); personList.Add("None"); persons.val = ""; } else if (selectPerson.val != "None") { hairAndClothing.val = "Person Name: " + selectPerson.val + "\n"; } loadDir = ""; string[] dirList = path.Split('/'); //bool tempBool = false; for (int i = 0; i < dirList.Count() - 1; i++) { loadDir = loadDir + dirList[i] + "/"; } string varName; if (path.Contains(":")) { varName = path.Substring(0, path.IndexOf(":")); if (varName.Length < 5) { varName = ""; } else { varName = varName + ":/"; } } else { varName = ""; } string tempPath = loadDir.Substring(0, loadDir.Length - 1); var charPosi = tempPath.IndexOf("Custom/Atom/Person/"); if (charPosi != -1) { vapPreviousFolder = varName + tempPath.Substring(charPosi); vapPreviousFolder = vapPreviousFolder.Replace("/", "\\"); } charPosi = tempPath.IndexOf("Saves/Person/"); if (charPosi != -1) { jsonPreviousFolder = varName + tempPath.Substring(charPosi); jsonPreviousFolder = jsonPreviousFolder.Replace("/", "\\"); } charPosi = tempPath.IndexOf("Saves/scene/"); if (charPosi != -1) { scenePreviousFolder = varName + tempPath.Substring(charPosi); scenePreviousFolder = scenePreviousFolder.Replace("/", "\\"); } if (path.Contains(":")) { SELF = path.Substring(0, path.IndexOf(":")); } //SuperController.LogMessage(SELF); //SuperController.LogMessage(path); LoadData = SuperController.singleton.ReadFileIntoString(path); jSONNode = JSON.Parse(LoadData); _isReset = true; bool jsonExt = (path.Substring(path.Length - 4, 4) != ".vap"); if (jsonExt) { atomArray = jSONNode["atoms"].AsArray; for (int k = 0; k < atomArray.Count; k++) { asAtomObject = atomArray[k].AsObject; id = asAtomObject["id"]; string type = asAtomObject["type"]; JSONArray tempArray = asAtomObject["storables"].AsArray; JSONClass tempObject; string characterType = ""; for (int l = 0; l < tempArray.Count; l++) { tempObject = tempArray[l].AsObject; string tempId = tempObject["id"]; if ("geometry" == tempId) { if (tempObject["character"] != null) { characterType = tempObject["character"]; } } } if (type == "Person") { if (sceneBool && selectPerson.val == "None") { personList.Add(id); persons.val = persons.val + id + " : " + characterType + "\n"; } asArray = asAtomObject["storables"].AsArray; } } if (sceneBool && selectPerson.val == "None") { if (personList.Count != 2) { selectPerson.choices = personList; return; } else { selectPerson.choices = personList; selectPerson.val = personList[1]; hairAndClothing.val = "Person Name: " + selectPerson.val + "\n"; } } if (sceneBool) { var m = 0; asObjectCUA = new Dictionary(); for (int k = 0; k < atomArray.Count; k++) { asAtomObject = atomArray[k].AsObject; id = asAtomObject["id"]; string type = asAtomObject["type"]; if (type == "Person" && id == selectPerson.val) { asArray = asAtomObject["storables"].AsArray; for (int l = 0; l < asArray.Count; l++) { asObject = asArray[l].AsObject; id = asObject["id"]; if (id == "control") { posi.x = float.Parse(asObject["position"][0]); posi.y = float.Parse(asObject["position"][1]); posi.z = float.Parse(asObject["position"][2]); sourcePositionDic[id] = posi; rota.x = float.Parse(asObject["rotation"][0]); rota.y = float.Parse(asObject["rotation"][1]); rota.z = float.Parse(asObject["rotation"][2]); sourceRotationDic[id] = rota; } else if (id == "hip") { if (asObject["relativeRootPosition"] != null && asObject["relativeRootRotation"] != null) { posi.x = float.Parse(asObject["relativeRootPosition"][0]); posi.y = float.Parse(asObject["relativeRootPosition"][1]); posi.z = float.Parse(asObject["relativeRootPosition"][2]); sourcePositionDic["relativeRootPosition"] = posi; rota.x = float.Parse(asObject["relativeRootRotation"][0]); rota.y = float.Parse(asObject["relativeRootRotation"][1]); rota.z = float.Parse(asObject["relativeRootRotation"][2]); sourceRotationDic["relativeRootRotation"] = rota; sourcePositionDic[id] = new Vector3(0, 0, 0); sourceRotationDic[id] = new Vector3(0, 0, 0); } else { sourcePositionDic["relativeRootPosition"] = new Vector3(0, 0, 0); sourceRotationDic["relativeRootRotation"] = new Vector3(0, 0, 0); sourcePositionDic[id] = new Vector3(0, 0, 0); sourceRotationDic[id] = new Vector3(0, 0, 0); } if (asObject["rootPosition"] != null && asObject["rootRotation"] != null) { posi.x = float.Parse(asObject["rootPosition"][0]); posi.y = float.Parse(asObject["rootPosition"][1]); posi.z = float.Parse(asObject["rootPosition"][2]); sourcePositionDic["rootPosition"] = posi; rota.x = float.Parse(asObject["rootRotation"][0]); rota.y = float.Parse(asObject["rootRotation"][1]); rota.z = float.Parse(asObject["rootRotation"][2]); sourceRotationDic["rootRotation"] = rota; } } else if (asObject["localPosition"] != null && asObject["localPosition"] != null) { id = asObject["id"]; posi.x = float.Parse(asObject["localPosition"][0]); posi.y = float.Parse(asObject["localPosition"][1]); posi.z = float.Parse(asObject["localPosition"][2]); sourcePositionDic[id] = posi; rota.x = float.Parse(asObject["localRotation"][0]); rota.y = float.Parse(asObject["localRotation"][1]); rota.z = float.Parse(asObject["localRotation"][2]); sourceRotationDic[id] = rota; } else if (asObject["position"] != null && asObject["rotation"] != null) { posi.x = float.Parse(asObject["position"][0]); posi.y = float.Parse(asObject["position"][1]); posi.z = float.Parse(asObject["position"][2]); sourcePositionDic[id] = posi; rota.x = float.Parse(asObject["rotation"][0]); rota.y = float.Parse(asObject["rotation"][1]); rota.z = float.Parse(asObject["rotation"][2]); sourceRotationDic[id] = rota; } } } if (type == "CustomUnityAsset") { var tempAsArray = asAtomObject["storables"].AsArray; for (int l = 0; l < tempAsArray.Count; l++) { var tempAsObject = tempAsArray[l].AsObject; string tempId = tempAsObject["id"]; if (tempId == "control") { if (tempAsObject["linkTo"] != null) { var sp = tempAsObject["linkTo"].ToString().Substring(1).Split(':'); if (sp[0] == selectPerson.val) { asObjectCUA[m] = atomArray[k].AsObject; m++; } } } } } } } } else { if (jSONNode["setUnlistedParamsToDefault"] != null) { _isReset = bool.Parse(jSONNode["setUnlistedParamsToDefault"]); hairAndClothing.val = hairAndClothing.val + "setUnlistedParamsToDefault: " + _isReset.ToString() + "\n"; } asArray = jSONNode["storables"].AsArray; } idListVap = new List(); pluginPreset = new JSONClass(); cuaPluginPreset = new JSONClass(); maleOnFemale = false; femeleOnMale = false; characterName = ""; int jn = 0; for (int i = 0; i < asArray.Count; i++) { asObject = asArray[i].AsObject; id = asObject["id"]; idListVap.Add(id); if (id == "geometry" && asObject["character"] != null) { characterName = asObject["character"]; } if (id == "geometry" && asObject["useMaleMorphsOnFemale"] != null) { maleOnFemale = bool.Parse(asObject["useMaleMorphsOnFemale"]); } if (id == "geometry" && asObject["useFemaleMorphsOnMale"] != null) { femeleOnMale = bool.Parse(asObject["useFemaleMorphsOnMale"]); } if (id == "geometry" && asObject["hair"] != null) { hairList = new List(); if (asObject["hair"].Count != 0) { hairAsArray = asObject["hair"].AsArray; for (int j = 0; j < hairAsArray.Count; j++) { hairAsObject = hairAsArray[j].AsObject; if (hairAsObject["id"] != null) { string hair = hairAsObject["id"]; if (hair.Substring(hair.Length - 4) == ".vam") { if (hairAsObject["internalId"] != null && hairAsObject["internalId"] != "") { hairList.Add(hairAsObject["internalId"]); } } else { if (hairAsObject["id"] != null && hairAsObject["id"] != "") { hairList.Add(hairAsObject["id"]); } } } else { if (hairAsObject["name"] != null && hairAsObject["name"] != "") { hairList.Add(hairAsObject["name"]); } } } } else { if (asObject["hair"] != null && asObject["hair"] != "") { hairList.Add(asObject["hair"]); } } hairList.Add("HairPresets"); hairList.Add("hairScalpMaskTool"); hairList.Add("HairSim"); hairList.Add("hairTool"); hairList.Add("Sim2Hair"); hairList.Add("V5ElitePonytail"); hairList.Add("VictoriaElitePonytail"); //hairList.Add("HairSimShortBangs"); //SuperController.LogMessage("hair"); } if (id == "geometry" && asObject["clothing"] != null) { clothingList = new List(); if (asObject["clothing"].Count != 0) { clothingAsArray = asObject["clothing"].AsArray; for (int j = 0; j < clothingAsArray.Count; j++) { clothingAsObject = clothingAsArray[j].AsObject; if (clothingAsObject["id"] != null) { string clothing = clothingAsObject["id"]; if (clothing.Substring(clothing.Length - 4) == ".vam") { clothingList.Add(clothingAsObject["internalId"]); string temp = clothingAsObject["internalId"]; temp = temp.Replace(" ", ""); clothingList.Add(temp); } else { clothingList.Add(clothingAsObject["id"]); string temp = clothingAsObject["id"]; temp = temp.Replace(" ", ""); clothingList.Add(temp); } } else if (clothingAsObject["name"] != null) { string clothing = clothingAsObject["name"]; if (clothing.Substring(clothing.Length - 4) == ".vam") { clothingList.Add(clothingAsObject["internalId"]); string temp = clothingAsObject["internalId"]; temp = temp.Replace(" ", ""); clothingList.Add(temp); } else { clothingList.Add(clothingAsObject["name"]); string temp = clothingAsObject["name"]; temp = temp.Replace(" ", ""); clothingList.Add(temp); } } } } } if (id == "rescaleObject") { if (scale_Bool.val) { if (asObject["scale"] != null) { scale = float.Parse(asObject["scale"]); } else { scale = 1f; } } } if (id == "PluginManager") { pluginPreset = new JSONClass(); if (asObject["plugins"] != null) { if (asObject["plugins"].Count != 0) { pluginPreset["setUnlistedParamsToDefault"] = "true"; pluginPreset["storables"][0]["id"] = "PluginManager"; var collection = asObject["plugins"].AsObject; foreach (var item in collection.Keys) { if (asObject["plugins"][item] != null) { if (asObject["plugins"][item].ToString().Contains("SELF:")) { pluginPreset["storables"][0]["plugins"][item] = asObject["plugins"][item].ToString().Replace("SELF:", SELF + ":").Replace("\"", ""); } else { pluginPreset["storables"][0]["plugins"][item] = asObject["plugins"][item]; } } } } } } if (id.Contains("plugin#")) { jn++; foreach (var item in asObject.Keys) { if (asObject[item] != null) { if (asObject[item].ToString().Contains("SELF:")) { pluginPreset["storables"][jn][item] = asObject[item].ToString().Replace("SELF:", SELF + ":").Replace("\"", ""); } else { pluginPreset["storables"][jn][item] = asObject[item]; } var subObject = asObject[item].AsObject; if (subObject != null) { foreach (var item2 in subObject.Keys) { if (asObject[item][item2] != null) { if (asObject[item][item2].ToString().Contains("SELF:")) { pluginPreset["storables"][jn][item][item2] = asObject[item][item2].ToString().Replace("SELF:", SELF + ":").Replace("\"", ""); } } } } } } } } geometry = TargetAtom.GetStorableByID("geometry"); character = geometry as DAZCharacterSelector; morphControl = character.morphsControlUI; paramControls = new Dictionary(); foreach (var item in idList) { if (TargetAtom.GetStorableByID(item) != null) { paramControls[item] = TargetAtom.GetStorableByID(item); } } makeDic(); message.val = "Processing"; missingItem.val = ""; StartCoroutine(applyData()); } IEnumerator applyData() { message.val = "Set New Character"; yield return setNewCharacter(); yield return new WaitForSeconds(1f); message.val = message.val + " ... done" + "\n"; if (textures_Bool.val) { message.val = message.val + "Clear Old Textures"; clearOldSkin(); yield return new WaitForSeconds(1f); message.val = message.val + " ... done" + "\n"; message.val = message.val + "Set New Textures"; setNewTextures(); yield return new WaitForSeconds(1f); message.val = message.val + " ... done" + "\n"; } message.val = message.val + "Clear Old Data"; clearOldData(); yield return new WaitForSeconds(1f); message.val = message.val + " ... done" + "\n"; message.val = message.val + "Morphs Copy"; yield return setNewData(); yield return new WaitForSeconds(1f); message.val = message.val + " ... done" + "\n"; if (hair_Bool.val) { message.val = message.val + "Clear Old Hair"; clearOldHair(); //yield return new WaitForSeconds(1f); message.val = message.val + " ... done" + "\n"; message.val = "Set New Hair"; setNewHair1(); yield return new WaitForSeconds(1f); message.val = message.val + " ... done" + "\n"; message.val = message.val + "Hair Copy"; setNewHair2(); yield return new WaitForSeconds(1f); message.val = message.val + " ... done" + "\n"; } if (clothing_Bool.val) { message.val = message.val + "Clear Old Clothing"; clearOldClothing(); message.val = message.val + " ... done" + "\n"; message.val = message.val + "Set New Clothing"; setNewClothing1(); yield return new WaitForSeconds(1f); message.val = message.val + " ... done" + "\n"; message.val = message.val + "Clothing copy"; setNewClothing2(); yield return new WaitForSeconds(1f); message.val = message.val + " ... done" + "\n"; } if (textures_Bool.val) { message.val = message.val + "Textures Copy"; yield return setNewTextures2(); yield return new WaitForSeconds(1f); message.val = message.val + " ... done" + "\n"; message.val = "Skin Change"; setNewSkin(); yield return new WaitForSeconds(5f); message.val = message.val + " ... done" + "\n"; } if (plugin_Bool.val) { message.val = message.val + "Load Plugin"; loadPlugin(); message.val = message.val + " ... done" + "\n"; } if (cua_Bool.val) { message.val = message.val + "Load CUA"; yield return loadCUA(); yield return new WaitForSeconds(2f); message.val = message.val + " ... done" + "\n"; } message.val = message.val + "Sim Enable"; simEnable(); message.val = message.val + " ... done" + "\n"; TargetAtom.collisionEnabledJSON.val = true; message.val = message.val + "Finished"; } private void clearOldData() { if (morphs_Bool.val) { if (_isReset || idListVap.Contains("geometry")) { geometry.GetBoolJSONParam("useAdvancedColliders").SetValToDefault(); geometry.GetBoolJSONParam("useAuxBreastColliders").SetValToDefault(); geometry.GetBoolJSONParam("disableAnatomy").SetValToDefault(); geometry.GetBoolJSONParam("useMaleMorphsOnFemale").SetValToDefault(); geometry.GetBoolJSONParam("useFemaleMorphsOnMale").SetValToDefault(); } if (_isReset || idListVap.Contains("JawControl")) { id = "JawControl"; if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetBoolJSONParam(item) != null) { paramControls[id].GetBoolJSONParam(item).SetValToDefault(); } if (paramControls[id].GetFloatJSONParam(item) != null) { paramControls[id].GetFloatJSONParam(item).SetValToDefault(); } } } } } if (_isReset || idListVap.Contains("BendFix")) { TargetAtom.GetStorableByID("BendFix").GetBoolJSONParam("enabled").SetValToDefault(); } if (_isReset || idListVap.Contains("FemaleAnatomy")) { TargetAtom.GetStorableByID("FemaleAnatomy").GetBoolJSONParam("enabled").SetValToDefault(); } if (_isReset || idListVap.Contains("BreastInOut")) { TargetAtom.GetStorableByID("BreastInOut").GetBoolJSONParam("enabled").SetValToDefault(); } if (_isReset || idListVap.Contains("EyelidControl")) { TargetAtom.GetStorableByID("EyelidControl").GetBoolJSONParam("eyelidLookMorphsEnabled").SetValToDefault(); } if (_isReset || idListVap.Contains("AutoJawMouthMorph")) { TargetAtom.GetStorableByID("AutoJawMouthMorph").GetBoolJSONParam("enabled").SetValToDefault(); } if (_isReset || idListVap.Contains("SoftBodyPhysicsEnabler")) { TargetAtom.GetStorableByID("SoftBodyPhysicsEnabler").GetBoolJSONParam("enabled").SetValToDefault(); } } if (breast_Bool.val && (_isReset || idListVap.Contains("BreastControl"))) { id = "BreastControl"; if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetFloatJSONParam(item) != null) { paramControls[id].GetFloatJSONParam(item).SetValToDefault(); } } } } } if (breast_Bool.val && (_isReset || idListVap.Contains("BreastPhysicsMesh"))) { id = "BreastPhysicsMesh"; if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetBoolJSONParam(item) != null) { paramControls[id].GetBoolJSONParam(item).SetValToDefault(); } if (paramControls[id].GetFloatJSONParam(item) != null) { paramControls[id].GetFloatJSONParam(item).SetValToDefault(); } } } } } if (glute_Bool.val && (_isReset || idListVap.Contains("GluteControl"))) { id = "GluteControl"; if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetFloatJSONParam(item) != null) { paramControls[id].GetFloatJSONParam(item).SetValToDefault(); } } } } } if (glute_Bool.val && (_isReset || idListVap.Contains("LowerPhysicsMesh"))) { id = "LowerPhysicsMesh"; if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetBoolJSONParam(item) != null) { paramControls[id].GetBoolJSONParam(item).SetValToDefault(); } if (paramControls[id].GetFloatJSONParam(item) != null) { paramControls[id].GetFloatJSONParam(item).SetValToDefault(); } } } } } if (textures_Bool.val && (_isReset || idListVap.Contains("FemaleEyelashes"))) { id = "FemaleEyelashes"; if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetBoolJSONParam(item) != null) { paramControls[id].GetBoolJSONParam(item).SetValToDefault(); } if (paramControls[id].GetFloatJSONParam(item) != null) { paramControls[id].GetFloatJSONParam(item).SetValToDefault(); } if (paramControls[id].GetColorJSONParam(item) != null) { paramControls[id].GetColorJSONParam(item).SetValToDefault(); } } } } } if (textures_Bool.val && (_isReset || idListVap.Contains("MaleEyelashes"))) { id = "MaleEyelashes"; if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetBoolJSONParam(item) != null) { paramControls[id].GetBoolJSONParam(item).SetValToDefault(); } if (paramControls[id].GetFloatJSONParam(item) != null) { paramControls[id].GetFloatJSONParam(item).SetValToDefault(); } if (paramControls[id].GetColorJSONParam(item) != null) { paramControls[id].GetColorJSONParam(item).SetValToDefault(); } } } } } if (eye_Bool.val && (_isReset || idListVap.Contains("irises"))) { id = "irises"; if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetBoolJSONParam(item) != null) { paramControls[id].GetBoolJSONParam(item).SetValToDefault(); } if (paramControls[id].GetFloatJSONParam(item) != null) { paramControls[id].GetFloatJSONParam(item).SetValToDefault(); } if (paramControls[id].GetUrlJSONParam(item) != null) { paramControls[id].GetUrlJSONParam(item).SetValToDefault(); } if (paramControls[id].GetColorJSONParam(item) != null) { paramControls[id].GetColorJSONParam(item).SetValToDefault(); } } } } } if (eye_Bool.val && (_isReset || idListVap.Contains("sclera"))) { id = "sclera"; if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetBoolJSONParam(item) != null) { paramControls[id].GetBoolJSONParam(item).SetValToDefault(); } if (paramControls[id].GetFloatJSONParam(item) != null) { paramControls[id].GetFloatJSONParam(item).SetValToDefault(); } if (paramControls[id].GetUrlJSONParam(item) != null) { paramControls[id].GetUrlJSONParam(item).SetValToDefault(); } if (paramControls[id].GetColorJSONParam(item) != null) { paramControls[id].GetColorJSONParam(item).SetValToDefault(); } } } } } if (eye_Bool.val && (_isReset || idListVap.Contains("lacrimals"))) { id = "lacrimals"; if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetBoolJSONParam(item) != null) { paramControls[id].GetBoolJSONParam(item).SetValToDefault(); } if (paramControls[id].GetFloatJSONParam(item) != null) { paramControls[id].GetFloatJSONParam(item).SetValToDefault(); } if (paramControls[id].GetUrlJSONParam(item) != null) { paramControls[id].GetUrlJSONParam(item).SetValToDefault(); } if (paramControls[id].GetColorJSONParam(item) != null) { paramControls[id].GetColorJSONParam(item).SetValToDefault(); } } } } } if (mouth_Bool.val && (_isReset || idListVap.Contains("teeth"))) { id = "teeth"; if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetBoolJSONParam(item) != null) { paramControls[id].GetBoolJSONParam(item).SetValToDefault(); } if (paramControls[id].GetFloatJSONParam(item) != null) { paramControls[id].GetFloatJSONParam(item).SetValToDefault(); } if (paramControls[id].GetUrlJSONParam(item) != null) { paramControls[id].GetUrlJSONParam(item).SetValToDefault(); } if (paramControls[id].GetColorJSONParam(item) != null) { paramControls[id].GetColorJSONParam(item).SetValToDefault(); } } } } } if (mouth_Bool.val && (_isReset || idListVap.Contains("tongue"))) { id = "tongue"; if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetBoolJSONParam(item) != null) { paramControls[id].GetBoolJSONParam(item).SetValToDefault(); } if (paramControls[id].GetFloatJSONParam(item) != null) { paramControls[id].GetFloatJSONParam(item).SetValToDefault(); } if (paramControls[id].GetUrlJSONParam(item) != null) { paramControls[id].GetUrlJSONParam(item).SetValToDefault(); } if (paramControls[id].GetColorJSONParam(item) != null) { paramControls[id].GetColorJSONParam(item).SetValToDefault(); } } } } } if (mouth_Bool.val && (_isReset || idListVap.Contains("mouth"))) { id = "mouth"; if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetBoolJSONParam(item) != null) { paramControls[id].GetBoolJSONParam(item).SetValToDefault(); } if (paramControls[id].GetFloatJSONParam(item) != null) { paramControls[id].GetFloatJSONParam(item).SetValToDefault(); } if (paramControls[id].GetUrlJSONParam(item) != null) { paramControls[id].GetUrlJSONParam(item).SetValToDefault(); } if (paramControls[id].GetColorJSONParam(item) != null) { paramControls[id].GetColorJSONParam(item).SetValToDefault(); } } } } } } private void clearOldSkin() { if (textures_Bool.val && (_isReset || idListVap.Contains("skin"))) { id = "skin"; if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetBoolJSONParam(item) != null) { paramControls[id].GetBoolJSONParam(item).SetValToDefault(); } if (paramControls[id].GetFloatJSONParam(item) != null) { paramControls[id].GetFloatJSONParam(item).SetValToDefault(); } if (paramControls[id].GetUrlJSONParam(item) != null) { paramControls[id].GetUrlJSONParam(item).SetValToDefault(); } if (paramControls[id].GetStringChooserJSONParam(item) != null) { paramControls[id].GetStringChooserJSONParam(item).SetValToDefault(); } if (paramControls[id].GetColorJSONParam(item) != null) { paramControls[id].GetColorJSONParam(item).SetValToDefault(); } } } } } if (textures_Bool.val && (_isReset || idListVap.Contains("textures"))) { id = "textures"; if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetBoolJSONParam(item) != null) { paramControls[id].GetBoolJSONParam(item).SetValToDefault(); } if (paramControls[id].GetFloatJSONParam(item) != null) { paramControls[id].GetFloatJSONParam(item).SetValToDefault(); } if (item.Contains("Url") && paramControls[id].GetUrlJSONParam(item) != null) { paramControls[id].GetUrlJSONParam(item).SetValToDefault(); } } } } //paramControls[id].GetBoolJSONParam("autoBlendGenitalTextures").val = false; //paramControls[id].GetBoolJSONParam("autoBlendGenitalSpecGlossNormalTextures").val = false; } } private void clearOldHair() { if (hair_Bool.val && (_isReset || idListVap.Contains("geometry"))) { var allHair = TargetAtom.GetStorableByID("geometry").GetBoolParamNames(); foreach (var item in allHair) { if (TargetAtom.GetStorableByID("geometry").GetBoolJSONParam(item).val && item.Contains("hair:")) { TargetAtom.GetStorableByID("geometry").GetBoolJSONParam(item).val = false; } } } } private void clearOldClothing() { if (clothing_Bool.val && !clothingMerge_Bool.val && (_isReset || idListVap.Contains("geometry"))) { var allClothing = TargetAtom.GetStorableByID("geometry").GetBoolParamNames(); foreach (var item in allClothing) { if (TargetAtom.GetStorableByID("geometry").GetBoolJSONParam(item).val && item.Contains("clothing:")) { TargetAtom.GetStorableByID("geometry").GetBoolJSONParam(item).val = false; } } } } private void setNewHair1() { if (hair_Bool.val) { for (int i = 0; i < asArray.Count; i++) { asObject = asArray[i].AsObject; id = asObject["id"]; if (id == "geometry" && asObject["hair"] != null) { if (asObject["hair"].Count != 0) { hairAsArray = asObject["hair"].AsArray; for (int j = 0; j < hairAsArray.Count; j++) { bool hit = false; hairAsObject = hairAsArray[j].AsObject; if (hairAsObject["id"] != null) { tempHair = hairAsObject["id"]; } else { tempHair = hairAsObject["name"]; } if (geometry.GetBoolJSONParam("hair:" + tempHair) != null) { hit = true; tempHair = "hair:" + tempHair; } else { if (tempHair.Contains(":/") && tempHair.Substring(tempHair.Length - 4) == ".vam") { string[] tempHairVar = tempHair.Split(':'); string[] tempHairName = tempHairVar[0].Split('.'); int ver = tempHairName.Count(); string tempName = ""; for (int k = 0; k < ver - 1; k++) { tempName = tempName + tempHairName[k] + "."; } string filenameVar; int varVer = 0; for (int k = 0; k < 100; k++) { filenameVar = tempName + k.ToString() + ":" + tempHairVar[1]; if (geometry.GetBoolJSONParam("hair:" + filenameVar) != null) { varVer = k; } } if (varVer != 0) { hit = true; tempHair = "hair:" + tempName + varVer.ToString() + ":" + tempHairVar[1]; } else { tempHair = tempHairVar[1].Substring(1); if (geometry.GetBoolJSONParam("hair:" + tempHair) != null) { hit = true; tempHair = "hair:" + tempHair; } } } if (!hit && !tempHair.Contains(":/") && tempHair.Contains(":") && !tempHair.Contains(".vam")) { string[] tempHairName = tempHair.Split(':'); foreach (var item in geometry.GetBoolParamNames()) { if (item.Contains(tempHairName[0]) && item.Contains("/" + tempHairName[1] + ".vam")) { hit = true; tempHair = item; } } if (!hit) { foreach (var item in geometry.GetBoolParamNames()) { if (item.Contains("/" + tempHairName[1] + ".vam")) { hit = true; tempHair = item; } } } } if (!hit) { string filenameVar; if (tempHair.Contains("/")) { string[] tempHairName = tempHair.Split('/'); filenameVar = "/" + tempHairName[tempHairName.Count() - 1]; } else { filenameVar = "/" + tempHair; } if (!filenameVar.Contains(".vam")) { filenameVar += ".vam"; } foreach (var item in geometry.GetBoolParamNames()) { if (item.Contains(filenameVar)) { hit = true; tempHair = item; } } } } //SuperController.LogMessage("test " + tempHair); //SuperController.LogMessage(hit.ToString()); //SuperController.LogMessage(""); if (hit && geometry.GetBoolJSONParam(tempHair) != null) { if (hairAsObject["enabled"] != null) { geometry.GetBoolJSONParam(tempHair).val = bool.Parse(hairAsObject["enabled"]); } else { geometry.GetBoolJSONParam(tempHair).val = true; } if (hairAsObject["internalId"] != null) { hairAndClothing.val = hairAndClothing.val + "Hair: " + hairAsObject["internalId"] + "\n"; } else if (hairAsObject["name"] != null) { hairAndClothing.val = hairAndClothing.val + "Hair: " + hairAsObject["name"] + "\n"; } else if (hairAsObject["id"] != null) { string temp = hairAsObject["id"]; if (!temp.Contains("/")) { hairAndClothing.val = hairAndClothing.val + "Hair: " + hairAsObject["id"] + "\n"; } else { string[] dir = temp.Split('/'); temp = dir[dir.Count() - 1]; hairAndClothing.val = hairAndClothing.val + "Hair: " + temp + "\n"; } } } else { missingItem.val = missingItem.val + "\nMissing Hair: " + tempHair; } } } else { string temp = asObject["hair"]; if (temp.Length > 1) { string tempHair = "hair:" + asObject["hair"]; if (geometry.GetBoolJSONParam(tempHair) != null) { geometry.GetBoolJSONParam(tempHair).val = true; } else { foreach (var item in geometry.GetBoolParamNames()) { if (item.Contains("/" + asObject["hair"] + ".vam")) { tempHair = item; } } geometry.GetBoolJSONParam(tempHair).val = true; } } } //SuperController.LogMessage(asObject["hair"]); } } } } private void setNewHair2() { if (hair_Bool.val) { for (int i = 0; i < asArray.Count; i++) { bool thisIsHair = false; asObject = asArray[i].AsObject; id = asObject["id"]; foreach (var item in hairList) { if (id.Contains(item)) { thisIsHair = true; } } if (thisIsHair) { hairAsObject = asArray[i].AsObject; if (TargetAtom.GetStorableByID(id) != null) { var param = hairAsObject.Keys; List collection = new List(); if (TargetAtom.GetStorableByID(id).GetUrlParamNames() != null) { collection = TargetAtom.GetStorableByID(id).GetUrlParamNames(); foreach (var item in collection) { if (param.Contains(item) && hairAsObject[item] != null) { string checkUrl = hairAsObject[item]; if (checkUrl.Contains(".")) { var fileUrl = checkPath(hairAsObject[item]); if (fileUrl != "") { TargetAtom.GetStorableByID(id).GetUrlJSONParam(item).val = fileUrl; } } } else if (param.Contains(item)) { TargetAtom.GetStorableByID(id).GetUrlJSONParam(item).val = ""; } } } if (TargetAtom.GetStorableByID(id).GetBoolParamNames() != null) { collection = TargetAtom.GetStorableByID(id).GetBoolParamNames(); foreach (var item in collection) { if (param.Contains(item) && hairAsObject[item] != null) { TargetAtom.GetStorableByID(id).GetBoolJSONParam(item).val = bool.Parse(hairAsObject[item]); } else if (param.Contains(item)) { TargetAtom.GetStorableByID(id).GetBoolJSONParam(item).SetValToDefault(); } } } if (TargetAtom.GetStorableByID(id).GetColorParamNames() != null) { collection = TargetAtom.GetStorableByID(id).GetColorParamNames(); foreach (var item in collection) { if (param.Contains(item) && hairAsObject[item] != null) { float h = float.Parse(asObject[item][0]); float s = float.Parse(asObject[item][1]); float v = float.Parse(asObject[item][2]); TargetAtom.GetStorableByID(id).GetColorJSONParam(item).SetColor(Color.HSVToRGB(h, s, v)); } else if (param.Contains(item)) { TargetAtom.GetStorableByID(id).GetColorJSONParam(item).SetValToDefault(); } } } if (TargetAtom.GetStorableByID(id).GetFloatParamNames() != null) { collection = TargetAtom.GetStorableByID(id).GetFloatParamNames(); foreach (var item in collection) { if (param.Contains(item) && hairAsObject[item] != null) { TargetAtom.GetStorableByID(id).GetFloatJSONParam(item).val = float.Parse(hairAsObject[item]); } else if (param.Contains(item)) { TargetAtom.GetStorableByID(id).GetFloatJSONParam(item).SetValToDefault(); } } } if (TargetAtom.GetStorableByID(id).GetStringParamNames() != null) { collection = TargetAtom.GetStorableByID(id).GetStringParamNames(); foreach (var item in collection) { if (param.Contains(item) && hairAsObject[item] != null) { TargetAtom.GetStorableByID(id).GetStringJSONParam(item).val = hairAsObject[item]; } else if (param.Contains(item)) { TargetAtom.GetStorableByID(id).GetStringJSONParam(item).SetValToDefault(); } } } if (TargetAtom.GetStorableByID(id).GetVector3ParamNames() != null) { collection = TargetAtom.GetStorableByID(id).GetVector3ParamNames(); foreach (var item in collection) { if (param.Contains(item) && hairAsObject[item] != null) { float x = float.Parse(asObject[item][0]); float y = float.Parse(asObject[item][1]); float z = float.Parse(asObject[item][2]); TargetAtom.GetStorableByID(id).GetVector3JSONParam(item).val = new Vector3(x, y, z); } else if (param.Contains(item)) { TargetAtom.GetStorableByID(id).GetVector3JSONParam(item).SetValToDefault(); } } } if (TargetAtom.GetStorableByID(id).GetStringChooserParamNames() != null) { collection = TargetAtom.GetStorableByID(id).GetStringChooserParamNames(); foreach (var item in collection) { if (param.Contains(item) && hairAsObject[item] != null) { TargetAtom.GetStorableByID(id).GetStringChooserJSONParam(item).val = hairAsObject[item]; } else if (param.Contains(item)) { TargetAtom.GetStorableByID(id).GetStringChooserJSONParam(item).SetValToDefault(); } } } if (TargetAtom.GetStorableByID(id).GetPresetFilePathActionNames() != null) { collection = TargetAtom.GetStorableByID(id).GetPresetFilePathActionNames(); foreach (var item in collection) { if (param.Contains(item)) { SuperController.LogMessage("No Hit in Hair item : " + item); } } } } } } } } private void setNewClothing1() { if (clothing_Bool.val) { for (int i = 0; i < asArray.Count; i++) { asObject = asArray[i].AsObject; id = asObject["id"]; if (id == "geometry" && asObject["clothing"] != null) { if (asObject["clothing"].Count != 0) { clothingAsArray = asObject["clothing"].AsArray; for (int j = 0; j < clothingAsArray.Count; j++) { bool hit = false; clothingAsObject = clothingAsArray[j].AsObject; if (clothingAsObject["id"] != null) { tempClothing = clothingAsObject["id"]; } else { tempClothing = clothingAsObject["name"]; } if (geometry.GetBoolJSONParam("clothing:" + tempClothing) != null) { hit = true; tempClothing = "clothing:" + tempClothing; } else { if (tempClothing.Contains(":/") && tempClothing.Substring(tempClothing.Length - 4) == ".vam") { string[] tempClothingVar = tempClothing.Split(':'); string[] tempClothingName = tempClothingVar[0].Split('.'); int ver = tempClothingName.Count(); string tempName = ""; for (int k = 0; k < ver - 1; k++) { tempName = tempName + tempClothingName[k] + "."; } string filenameVar; int varVer = 0; for (int k = 0; k < 100; k++) { filenameVar = tempName + k.ToString() + ":" + tempClothingVar[1]; if (geometry.GetBoolJSONParam("clothing:" + filenameVar) != null) { varVer = k; } } if (varVer != 0) { hit = true; tempClothing = "clothing:" + tempName + varVer.ToString() + ":" + tempClothingVar[1]; } else { tempClothing = tempClothingVar[1].Substring(1); if (geometry.GetBoolJSONParam("clothing:" + tempClothing) != null) { hit = true; tempClothing = "clothing:" + tempClothing; } } } if (!hit && tempClothing.Contains(":") && !tempClothing.Contains(".vam")) { string[] tempClothingName = tempClothing.Split(':'); foreach (var item in geometry.GetBoolParamNames()) { if (item.Contains(tempClothingName[0]) && item.Contains("/" + tempClothingName[1] + ".vam")) { hit = true; tempClothing = item; } } if (!hit) { foreach (var item in geometry.GetBoolParamNames()) { if (item.Contains("/" + tempClothingName[1] + ".vam")) { hit = true; tempClothing = item; } } } } if (!hit) { string filenameVar; if (tempClothing.Contains("/")) { string[] tempClothingName = tempClothing.Split('/'); filenameVar = "/" + tempClothingName[tempClothingName.Count() - 1]; } else { filenameVar = "/" + tempClothing; } if (!filenameVar.Contains(".vam")) { filenameVar += ".vam"; } foreach (var item in geometry.GetBoolParamNames()) { if (item.Contains(filenameVar)) { hit = true; tempClothing = item; } } } } //SuperController.LogMessage("test " + tempClothing); //SuperController.LogMessage(hit.ToString()); //SuperController.LogMessage(""); if (hit && geometry.GetBoolJSONParam(tempClothing) != null) { if (clothingAsObject["enabled"] != null) { geometry.GetBoolJSONParam(tempClothing).val = bool.Parse(clothingAsObject["enabled"]); } else { geometry.GetBoolJSONParam(tempClothing).val = true; } if (clothingAsObject["internalId"] != null) { hairAndClothing.val = hairAndClothing.val + "Clothing: " + clothingAsObject["internalId"] + "\n"; } else if (clothingAsObject["name"] != null) { hairAndClothing.val = hairAndClothing.val + "Clothing: " + clothingAsObject["name"] + "\n"; } else if (clothingAsObject["id"] != null) { string temp = clothingAsObject["id"]; if (!temp.Contains("/")) { hairAndClothing.val = hairAndClothing.val + "Clothing: " + clothingAsObject["id"] + "\n"; } else { string[] dir = temp.Split('/'); temp = dir[dir.Count() - 1]; hairAndClothing.val = hairAndClothing.val + "Clothing: " + temp + "\n"; } } } else { missingItem.val = missingItem.val + "\nMissing Clothing:" + tempClothing; } } } else { string temp = asObject["clothing"]; if (temp.Length > 1) { string tempClothing = "clothing:" + asObject["clothing"]; if (geometry.GetBoolJSONParam(tempClothing) != null) { geometry.GetBoolJSONParam(tempClothing).val = true; } else { foreach (var item in geometry.GetBoolParamNames()) { if (item.Contains("/" + asObject["clothing"] + ".vam")) { tempClothing = item; } } geometry.GetBoolJSONParam(tempClothing).val = true; } } } } } simClothingDic = new Dictionary(); simClothingList = new List(); var tempId = TargetAtom.GetStorableIDs(); foreach (var item in tempId) { if (TargetAtom.GetStorableByID(item).GetBoolParamNames() != null) { var tempBool = TargetAtom.GetStorableByID(item).GetBoolParamNames(); if (tempBool.Contains("simEnabled")) { simClothingList.Add(item); simClothingDic[item] = TargetAtom.GetStorableByID(item).GetBoolJSONParam("simEnabled").defaultVal; TargetAtom.GetStorableByID(item).GetBoolJSONParam("simEnabled").val = false; } } } } } private void setNewClothing2() { if (clothing_Bool.val) { var rigid = TargetAtom.rigidbodies; List rigidList = new List(); foreach (var item in rigid) { rigidList.Add(item.name); } foreach (var item in idList) { rigidList.Add(item); } foreach (var item in idList2) { rigidList.Add(item); } foreach (var item in idList3) { rigidList.Add(item); } for (int i = 0; i < asArray.Count; i++) { bool thisIsClothing = true; asObject = asArray[i].AsObject; id = asObject["id"]; if (rigidList.Contains(id) | id.Contains("plugin#") | id.Contains("Animation") | id.Contains("animation")) { thisIsClothing = false; } foreach (var item in hairList) { if (item != "") { if (id.Contains(item)) { thisIsClothing = false; } } } //thisIsClothing = false; foreach (var item in clothingList) { if (id.Contains(item)) { thisIsClothing = true; } } if (thisIsClothing) { clothingAsObject = asArray[i].AsObject; if (TargetAtom.GetStorableByID(id) != null) { var param = clothingAsObject.Keys; { List collection = new List(); if (TargetAtom.GetStorableByID(id).GetUrlParamNames() != null) { collection = TargetAtom.GetStorableByID(id).GetUrlParamNames(); //SuperController.LogMessage("Url"); foreach (var item in collection) { if (param.Contains(item) && clothingAsObject[item] != null) { string checkUrl = clothingAsObject[item]; if (checkUrl.Contains(".")) { var fileUrl = checkPath(clothingAsObject[item]); if (fileUrl != "") { TargetAtom.GetStorableByID(id).GetUrlJSONParam(item).val = fileUrl; } } } else if (param.Contains(item)) { TargetAtom.GetStorableByID(id).GetUrlJSONParam(item).val = ""; } } } if (TargetAtom.GetStorableByID(id).GetBoolParamNames() != null) { collection = TargetAtom.GetStorableByID(id).GetBoolParamNames(); //SuperController.LogMessage("Bool"); foreach (var item in collection) { if (param.Contains(item) && clothingAsObject[item] != null) { if (item == "simEnabled") { //TargetAtom.GetStorableByID(id).GetBoolJSONParam(item).val = false; simClothingDic[item] = bool.Parse(clothingAsObject[item]); //SuperController.LogMessage(item + " cloth2 " + clothingAsObject[item].ToString()); } else { TargetAtom.GetStorableByID(id).GetBoolJSONParam(item).val = bool.Parse(clothingAsObject[item]); } } else if (param.Contains(item)) { if (item == "simEnabled") { //TargetAtom.GetStorableByID(id).GetBoolJSONParam(item).val = false; //simClothingDic[item] = true; } else { TargetAtom.GetStorableByID(id).GetBoolJSONParam(item).SetValToDefault(); } } } } if (TargetAtom.GetStorableByID(id).GetColorParamNames() != null) { collection = TargetAtom.GetStorableByID(id).GetColorParamNames(); //SuperController.LogMessage("Color"); foreach (var item in collection) { if (param.Contains(item) && clothingAsObject[item] != null) { float h = float.Parse(asObject[item][0]); float s = float.Parse(asObject[item][1]); float v = float.Parse(asObject[item][2]); TargetAtom.GetStorableByID(id).GetColorJSONParam(item).SetColor(Color.HSVToRGB(h, s, v)); } else if (param.Contains(item)) { TargetAtom.GetStorableByID(id).GetColorJSONParam(item).SetValToDefault(); } } } if (TargetAtom.GetStorableByID(id).GetFloatParamNames() != null) { collection = TargetAtom.GetStorableByID(id).GetFloatParamNames(); //SuperController.LogMessage("Float"); foreach (var item in collection) { if (param.Contains(item) && clothingAsObject[item] != null) { TargetAtom.GetStorableByID(id).GetFloatJSONParam(item).val = float.Parse(clothingAsObject[item]); } else if (param.Contains(item)) { TargetAtom.GetStorableByID(id).GetFloatJSONParam(item).SetValToDefault(); } } } if (TargetAtom.GetStorableByID(id).GetStringParamNames() != null) { collection = TargetAtom.GetStorableByID(id).GetStringParamNames(); //SuperController.LogMessage("String"); foreach (var item in collection) { if (param.Contains(item) && clothingAsObject[item] != null) { TargetAtom.GetStorableByID(id).GetStringJSONParam(item).val = clothingAsObject[item]; } else if (param.Contains(item)) { TargetAtom.GetStorableByID(id).GetStringJSONParam(item).SetValToDefault(); } } } if (TargetAtom.GetStorableByID(id).GetVector3ParamNames() != null) { collection = TargetAtom.GetStorableByID(id).GetVector3ParamNames(); //SuperController.LogMessage("Vector3"); foreach (var item in collection) { if (param.Contains(item) && clothingAsObject[item] != null) { float x = float.Parse(asObject[item][0]); float y = float.Parse(asObject[item][1]); float z = float.Parse(asObject[item][2]); TargetAtom.GetStorableByID(id).GetVector3JSONParam(item).val = new Vector3(x, y, z); } else if (param.Contains(item)) { TargetAtom.GetStorableByID(id).GetVector3JSONParam(item).SetValToDefault(); } } } if (TargetAtom.GetStorableByID(id).GetStringChooserParamNames() != null) { collection = TargetAtom.GetStorableByID(id).GetStringChooserParamNames(); //SuperController.LogMessage("StringChooser"); foreach (var item in collection) { if (param.Contains(item) && clothingAsObject[item] != null) { TargetAtom.GetStorableByID(id).GetStringChooserJSONParam(item).val = clothingAsObject[item]; } else if (param.Contains(item)) { TargetAtom.GetStorableByID(id).GetStringChooserJSONParam(item).SetValToDefault(); } } } if (TargetAtom.GetStorableByID(id).GetPresetFilePathActionNames() != null) { collection = TargetAtom.GetStorableByID(id).GetPresetFilePathActionNames(); //SuperController.LogMessage("Preset"); foreach (var item in collection) { if (param.Contains(item)) { SuperController.LogMessage("No Hit in Clothing item : " + item); } } } } } } } } } //IEnumerator simEnable() private void simEnable() { foreach (var item in simClothingList) { TargetAtom.GetStorableByID(item).GetBoolJSONParam("simEnabled").val = simClothingDic[item]; //TargetAtom.GetStorableByID(item).GetBoolJSONParam("simEnabled").val = true; } } IEnumerator setNewCharacter() { if (textures_Bool.val && characterName != "") { //character.characterSelectorUI.characterSelector.SetStringChooserParamValue("characterSelection", characterName);} if (morphs_Bool.val) { if (femeleOnMale) { geometry.GetStringChooserJSONParam("characterSelection").val = "Female Custom"; yield return new WaitForSeconds(1f); //geometry = TargetAtom.GetStorableByID("geometry"); //character = geometry as DAZCharacterSelector; morphControl = character.morphsControlUI; DAZMorph morph; morphControl.GetMorphUids().ForEach((uid) => { morph = morphControl.GetMorphByUid(uid); if (!morph.isPoseControl) { morph.SetDefaultValue(); } }); yield return new WaitForSeconds(1f); } if (maleOnFemale) { geometry.GetStringChooserJSONParam("characterSelection").val = "Male Custom"; yield return new WaitForSeconds(1f); //geometry = TargetAtom.GetStorableByID("geometry"); //character = geometry as DAZCharacterSelector; morphControl = character.morphsControlUI; DAZMorph morph; morphControl.GetMorphUids().ForEach((uid) => { morph = morphControl.GetMorphByUid(uid); if (!morph.isPoseControl) { morph.SetDefaultValue(); } }); yield return new WaitForSeconds(1f); } } geometry.GetStringChooserJSONParam("characterSelection").val = characterName; geometry = TargetAtom.GetStorableByID("geometry"); character = geometry as DAZCharacterSelector; morphControl = character.morphsControlUI; yield return new WaitForSeconds(1f); makeDic(); paramControls = new Dictionary(); foreach (var item in idList) { if (TargetAtom.GetStorableByID(item) != null) { paramControls[item] = TargetAtom.GetStorableByID(item); } } } } IEnumerator changeMorph() { if (scale_Bool.val) { if (idListVap.Contains("rescaleObject")) { TargetAtom.GetStorableByID("rescaleObject").GetFloatJSONParam("scale").val = scale; } else { TargetAtom.GetStorableByID("rescaleObject").GetFloatJSONParam("scale").val = 1f; } yield return new WaitForSeconds(0.1f); } if (morphs_Bool.val) { List keyList = new List(); Dictionary morphDic = new Dictionary(); for (int i = 0; i < asArray.Count; i++) { asObject = asArray[i].AsObject; id = asObject["id"]; if (id == "geometry") { morphsAsArray = asObject["morphs"].AsArray; for (int j = 0; j < morphsAsArray.Count; j++) { morphs = morphsAsArray[j].AsObject; if (morphs["value"] != null) { keyList.Add(morphs["name"]); morphDic[morphs["name"]] = morphs["value"]; } } } } DAZMorph morph; if (idListVap.Contains("geometry") || _isReset) { morphControl.GetMorphUids().ForEach((uid) => { morph = morphControl.GetMorphByUid(uid); if (!morph.isPoseControl) { morph.SetDefaultValue(); } }); yield return new WaitForSeconds(1f); morphControl.GetMorphUids().ForEach((uid) => { morph = morphControl.GetMorphByUid(uid); if (!morph.isPoseControl && !keyList.Contains(morph.displayName)) { morph.SetDefaultValue(); } }); yield return new WaitForSeconds(1f); } foreach (var item in keyList) { if (morphControl.GetMorphByDisplayName(item) != null) { if (!morphControl.GetMorphByDisplayName(item).isPoseControl) { morphControl.GetMorphByDisplayName(item).morphValue = float.Parse(morphDic[item]); yield return new WaitForSeconds(0.02f); } } } yield return new WaitForSeconds(1f); } } IEnumerator setNewData() { //StartCoroutine(changeMorph()); for (int i = 0; i < asArray.Count; i++) { asObject = asArray[i].AsObject; id = asObject["id"]; if (morphs_Bool.val) { if (id == "geometry") { if (asObject["useAdvancedColliders"] != null) { geometry.GetBoolJSONParam("useAdvancedColliders").val = bool.Parse(asObject["useAdvancedColliders"]); } if (asObject["useAuxBreastColliders"] != null) { geometry.GetBoolJSONParam("useAuxBreastColliders").val = bool.Parse(asObject["useAuxBreastColliders"]); } if (asObject["disableAnatomy"] != null) { geometry.GetBoolJSONParam("disableAnatomy").val = bool.Parse(asObject["disableAnatomy"]); } if (asObject["useMaleMorphsOnFemale"] != null) { geometry.GetBoolJSONParam("useMaleMorphsOnFemale").val = bool.Parse(asObject["useMaleMorphsOnFemale"]); } if (asObject["useFemaleMorphsOnMale"] != null) { geometry.GetBoolJSONParam("useFemaleMorphsOnMale").val = bool.Parse(asObject["useFemaleMorphsOnMale"]); } } if (id == "JawControl") { foreach (var item in idDic[id]) { if (paramControls[id].GetBoolJSONParam(item) != null && asObject[item] != null) { paramControls[id].GetBoolJSONParam(item).val = bool.Parse(asObject[item]); } else if (paramControls[id].GetFloatJSONParam(item) != null && asObject[item] != null) { paramControls[id].GetFloatJSONParam(item).val = float.Parse(asObject[item]); } } } if (id == "BendFix" && asObject["enabled"] != null) { TargetAtom.GetStorableByID(id).GetBoolJSONParam("enabled").val = bool.Parse(asObject["enabled"]); } if (id == "FemaleAnatomy" && asObject["enabled"] != null) { TargetAtom.GetStorableByID(id).GetBoolJSONParam("enabled").val = bool.Parse(asObject["enabled"]); } if (id == "BreastInOut" && asObject["enabled"] != null) { TargetAtom.GetStorableByID(id).GetBoolJSONParam("enabled").val = bool.Parse(asObject["enabled"]); } if (id == "EyelidControl" && asObject["eyelidLookMorphsEnabled"] != null) { TargetAtom.GetStorableByID(id).GetBoolJSONParam("eyelidLookMorphsEnabled").val = bool.Parse(asObject["eyelidLookMorphsEnabled"]); } if (id == "AutoJawMouthMorph" && asObject["enabled"] != null) { TargetAtom.GetStorableByID(id).GetBoolJSONParam("enabled").val = bool.Parse(asObject["enabled"]); } if (id == "AutoExpressions" && asObject["enabled"] != null) { TargetAtom.GetStorableByID(id).GetBoolJSONParam("enabled").val = bool.Parse(asObject["enabled"]); } if (id == "SoftBodyPhysicsEnabler" && asObject["enabled"] != null) { TargetAtom.GetStorableByID(id).GetBoolJSONParam("enabled").val = bool.Parse(asObject["enabled"]); } } if (breast_Bool.val) { if (id == "BreastControl" | id == "BreastPhysicsMesh") { foreach (var item in idDic[id]) { if (paramControls[id].GetBoolJSONParam(item) != null && asObject[item] != null) { paramControls[id].GetBoolJSONParam(item).val = bool.Parse(asObject[item]); } else if (paramControls[id].GetFloatJSONParam(item) != null && asObject[item] != null) { paramControls[id].GetFloatJSONParam(item).val = float.Parse(asObject[item]); } } } } if (glute_Bool.val) { if (id == "GluteControl" | id == "LowerPhysicsMesh") { foreach (var item in idDic[id]) { if (paramControls[id].GetBoolJSONParam(item) != null && asObject[item] != null) { paramControls[id].GetBoolJSONParam(item).val = bool.Parse(asObject[item]); } else if (paramControls[id].GetFloatJSONParam(item) != null && asObject[item] != null) { paramControls[id].GetFloatJSONParam(item).val = float.Parse(asObject[item]); } } } } if (eye_Bool.val) { if (id == "FemaleEyelashes" | id == "MaleEyelashes" | id == "irises" | id == "sclera" | id == "lacrimals") { if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetBoolJSONParam(item) != null && asObject[item] != null) { paramControls[id].GetBoolJSONParam(item).val = bool.Parse(asObject[item]); } else if (paramControls[id].GetStringChooserJSONParam(item) != null && asObject[item] != null) { paramControls[id].GetStringChooserJSONParam(item).val = asObject[item]; } else if (paramControls[id].GetColorJSONParam(item) != null && asObject[item] != null && asObject[item].Count >= 3) { float h = float.Parse(asObject[item][0]); float s = float.Parse(asObject[item][1]); float v = float.Parse(asObject[item][2]); paramControls[id].GetColorJSONParam(item).SetColor(Color.HSVToRGB(h, s, v)); } else if (paramControls[id].GetUrlJSONParam(item) != null && asObject[item] != null) { string checkUrl = asObject[item]; if (checkUrl.Contains(".")) { var fileUrl = checkPath(asObject[item]); if (fileUrl != "") { paramControls[id].GetUrlJSONParam(item).val = fileUrl; } } } else if (paramControls[id].GetFloatJSONParam(item) != null && asObject[item] != null) { paramControls[id].GetFloatJSONParam(item).val = float.Parse(asObject[item]); } } } } } } if (mouth_Bool.val) { if (id == "teeth" | id == "tongue" | id == "mouth") { if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetBoolJSONParam(item) != null && asObject[item] != null) { paramControls[id].GetBoolJSONParam(item).val = bool.Parse(asObject[item]); } else if (paramControls[id].GetStringChooserJSONParam(item) != null && asObject[item] != null) { paramControls[id].GetStringChooserJSONParam(item).val = asObject[item]; } else if (paramControls[id].GetColorJSONParam(item) != null && asObject[item] != null && asObject[item].Count >= 3) { float h = float.Parse(asObject[item][0]); float s = float.Parse(asObject[item][1]); float v = float.Parse(asObject[item][2]); paramControls[id].GetColorJSONParam(item).SetColor(Color.HSVToRGB(h, s, v)); } else if (paramControls[id].GetUrlJSONParam(item) != null && asObject[item] != null) { string checkUrl = asObject[item]; if (checkUrl.Contains(".")) { var fileUrl = checkPath(asObject[item]); if (fileUrl != "") { paramControls[id].GetUrlJSONParam(item).val = fileUrl; } } } else if (paramControls[id].GetFloatJSONParam(item) != null && asObject[item] != null) { paramControls[id].GetFloatJSONParam(item).val = float.Parse(asObject[item]); } } } } } } } yield return StartCoroutine(changeMorph()); } private void setNewTextures() { if (textures_Bool.val) { for (int i = 0; i < asArray.Count; i++) { asObject = asArray[i].AsObject; id = asObject["id"]; if (id == "textures") { if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetUrlJSONParam(item) != null && asObject[item] != null) { string checkUrl = asObject[item]; if (checkUrl.Contains(".")) { var fileUrl = checkPath(asObject[item]); if (fileUrl != "") { paramControls[id].GetUrlJSONParam(item).val = fileUrl; } } } } } } } } } } IEnumerator setNewTextures2() { if (textures_Bool.val) { yield return new WaitForSeconds(2f); for (int i = 0; i < asArray.Count; i++) { asObject = asArray[i].AsObject; id = asObject["id"]; if (id == "textures") { if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetFloatJSONParam(item) != null && asObject[item] != null) { paramControls[id].GetFloatJSONParam(item).val = float.Parse(asObject[item]); } if (paramControls[id].GetBoolJSONParam(item) != null && asObject[item] != null) { paramControls[id].GetBoolJSONParam(item).val = bool.Parse(asObject[item]); } } } } } } } } private void setNewSkin() { for (int i = 0; i < asArray.Count; i++) { asObject = asArray[i].AsObject; id = asObject["id"]; if (textures_Bool.val && id == "skin") { if (idDic.Keys.Contains(id)) { if (idDic[id] != null && paramControls[id] != null) { foreach (var item in idDic[id]) { if (paramControls[id].GetBoolJSONParam(item) != null && asObject[item] != null) { paramControls[id].GetBoolJSONParam(item).val = bool.Parse(asObject[item]); } else if (paramControls[id].GetStringChooserJSONParam(item) != null && asObject[item] != null) { paramControls[id].GetStringChooserJSONParam(item).val = asObject[item]; } else if (paramControls[id].GetColorJSONParam(item) != null && asObject[item] != null && asObject[item].Count >= 3) { float h = float.Parse(asObject[item][0]); float s = float.Parse(asObject[item][1]); float v = float.Parse(asObject[item][2]); paramControls[id].GetColorJSONParam(item).SetColor(Color.HSVToRGB(h, s, v)); } else if (paramControls[id].GetUrlJSONParam(item) != null && asObject[item] != null) { var fileUrl = checkPath(asObject[item]); if (fileUrl != "") { paramControls[id].GetUrlJSONParam(item).val = fileUrl; } } else if (paramControls[id].GetFloatJSONParam(item) != null && asObject[item] != null) { paramControls[id].GetFloatJSONParam(item).val = float.Parse(asObject[item]); } } } } } } } IEnumerator loadCUA() { if (cua_Bool.val && sceneBool) { if (asObjectCUA != null) { if (asObjectCUA.Count() != 0) { for (var i = 0; i < asObjectCUA.Count(); i++) { SuperController.singleton.PauseSimulation(10, "Cloning"); var tempAsObject = asObjectCUA[i]; string cuaName = tempAsObject["id"]; emptyName = "Empty_for_AppearanceLoader"; //SuperController.LogMessage(cuaName); yield return StartCoroutine(SuperController.singleton.AddAtomByType("Empty", emptyName, false, true)); yield return new WaitForSeconds(1f); yield return StartCoroutine(SuperController.singleton.AddAtomByType("CustomUnityAsset", cuaName, false, true)); yield return new WaitForSeconds(1f); Atom addedCUA = SuperController.singleton.GetSelectedAtom(); if (tempAsObject["collisionEnabled"] != null) { addedCUA.GetBoolJSONParam("collisionEnabled").val = bool.Parse(tempAsObject["collisionEnabled"]); } addedCUA.GetBoolJSONParam("on").val = false; var tempAsArray = tempAsObject["storables"].AsArray; int jn = 0; for (int j = 0; j < tempAsArray.Count; j++) { tempAsObject = tempAsArray[j].AsObject; string id = tempAsObject["id"]; if (id == "asset") { var cuaControl = addedCUA.GetStorableByID("asset"); foreach (var item in tempAsObject.Keys) { if (tempAsObject[item] != null) { if (cuaControl.GetBoolJSONParam(item) != null) { cuaControl.GetBoolJSONParam(item).val = bool.Parse(tempAsObject[item]); } else if (cuaControl.GetFloatJSONParam(item) != null) { cuaControl.GetFloatJSONParam(item).val = float.Parse(tempAsObject[item]); } else if (cuaControl.GetStringChooserJSONParam(item) != null) { cuaControl.GetStringChooserJSONParam(item).val = tempAsObject[item]; yield return new WaitForSeconds(1f); } else if (cuaControl.GetStringJSONParam(item) != null) { cuaControl.GetStringJSONParam(item).val = tempAsObject[item]; } else if (cuaControl.GetUrlJSONParam(item) != null) { string checkUrl = tempAsObject[item]; if (checkUrl.Contains(".")) { var fileUrl = checkPath(tempAsObject[item]); if (fileUrl != "") { cuaControl.GetUrlJSONParam(item).val = fileUrl; } yield return new WaitForSeconds(1f); } } } } if (tempAsObject["assetName"] != null) { cuaControl.GetStringChooserJSONParam("assetName").val = tempAsObject["assetName"]; yield return new WaitForSeconds(1f); hairAndClothing.val = hairAndClothing.val + "CUA: " + tempAsObject["assetName"] + "\n"; } } if (id == "scale") { if (tempAsObject["scale"] != null) { addedCUA.GetStorableByID("scale").GetFloatJSONParam("scale").val = float.Parse(tempAsObject["scale"]); } } if (id == "Preset") { if (tempAsObject["presetName"] != null) { addedCUA.GetStorableByID("Preset").GetStringJSONParam("presetName").val = tempAsObject["presetName"]; addedCUA.GetStorableByID("Preset").CallAction("LoadPreset"); } } if (id == "PluginManager") { cuaPluginPreset = new JSONClass(); if (tempAsObject["plugins"] != null) { if (tempAsObject["plugins"].Count != 0) { cuaPluginPreset["setUnlistedParamsToDefault"] = "true"; cuaPluginPreset["storables"][0]["id"] = "PluginManager"; var collection = tempAsObject["plugins"].AsObject; foreach (var item in collection.Keys) { if (tempAsObject["plugins"][item] != null) { if (tempAsObject["plugins"][item].ToString().Contains("SELF:")) { cuaPluginPreset["storables"][0]["plugins"][item] = tempAsObject["plugins"][item].ToString().Replace("SELF:", SELF + ":").Replace("\"", ""); } else { cuaPluginPreset["storables"][0]["plugins"][item] = tempAsObject["plugins"][item]; } } } } } } if (id.Contains("plugin#")) { jn++; foreach (var item in tempAsObject.Keys) { if (tempAsObject[item] != null) { if (tempAsObject[item].ToString().Contains("SELF:")) { cuaPluginPreset["storables"][jn][item] = tempAsObject[item].ToString().Replace("SELF:", SELF + ":").Replace("\"", ""); } else { cuaPluginPreset["storables"][jn][item] = tempAsObject[item]; } var cuaSubObject = tempAsObject[item].AsObject; if (cuaSubObject != null) { foreach (var item2 in cuaSubObject.Keys) { if (tempAsObject[item][item2] != null) { if (tempAsObject[item][item2].ToString().Contains("SELF:")) { cuaPluginPreset["storables"][jn][item][item2] = tempAsObject[item][item2].ToString().Replace("SELF:", SELF + ":").Replace("\"", ""); } } } } } } } if (id == "control") { FreeControllerV3 cuaControl = addedCUA.GetStorableByID("control") as FreeControllerV3; foreach (var item in tempAsObject.Keys) { if (item == "linkTo") { if (tempAsObject["linkTo"] != null) { string linkTo = tempAsObject["linkTo"]; linkTo = linkTo.Replace("\"", ""); string[] link = linkTo.Split(':'); posi.x = float.Parse(tempAsObject["position"][0]); posi.y = float.Parse(tempAsObject["position"][1]); posi.z = float.Parse(tempAsObject["position"][2]); rota.x = float.Parse(tempAsObject["rotation"][0]); rota.y = float.Parse(tempAsObject["rotation"][1]); rota.z = float.Parse(tempAsObject["rotation"][2]); targetPosi = new Vector3(0, 0, 0); targetRota = new Vector3(0, 0, 0); Atom empty = SuperController.singleton.GetAtomByUid(emptyName); FreeControllerV3 emptyControl = empty.GetStorableByID("control") as FreeControllerV3; if (rigidbodies.Contains(link[1])) { List rbList = new List(); _rigid = TargetAtom.rigidbodies.First(rb => rb.name == link[1]); string rigidName = link[1]; rbList.Add(rigidName); //targetRota = sourceRotationDic[rigidName]; while (rigidName != "hip") { GameObject parent = _rigid.transform.parent.gameObject; rigidName = parent.name; rbList.Add(rigidName); _rigid = TargetAtom.rigidbodies.First(rb => rb.name == rigidName); //targetRota += sourceRotationDic[rigidName]; } rbList.Reverse(); rootPosi = sourcePositionDic["rootPosition"]; rootRota = sourceRotationDic["rootRotation"]; tempPosi = rootPosi; tempRota = rootRota; foreach (var rbName in rbList) { if (rbName == "hip") { emptyControl.transform.position = rootPosi; emptyControl.transform.rotation = Quaternion.Euler(rootRota); /* SuperController.LogMessage(rbName); display("posi ", rootPosi); display("rota ", rootRota); _rigid = TargetAtom.rigidbodies.First(rb => rb.name == rbName); var rigidPosi = _rigid.transform.position; var rigidRota = _rigid.transform.rotation.eulerAngles; display("posi ", rigidPosi); display("rota ", rigidRota); SuperController.LogMessage(""); */ } else { tempPosi = emptyControl.transform.TransformPoint(sourcePositionDic[rbName]); tempRota += sourceRotationDic[rbName]; emptyControl.transform.position = tempPosi; emptyControl.transform.rotation *= Quaternion.Euler(sourceRotationDic[rbName]); /* SuperController.LogMessage(rbName); display("posi ", tempPosi); display("rota ", tempRota); display("rota ", emptyControl.transform.rotation.eulerAngles); _rigid = TargetAtom.rigidbodies.First(rb => rb.name == rbName); var rigidPosi = _rigid.transform.position; var rigidRota = _rigid.transform.rotation.eulerAngles; display("posi ", rigidPosi); display("rota ", rigidRota); SuperController.LogMessage(""); */ } } //emptyControl.transform.position = tempPosi; cuaControl.transform.position = posi; cuaControl.transform.rotation = Quaternion.Euler(rota); localPosi = emptyControl.transform.InverseTransformPoint(posi); localRota = emptyControl.transform.rotation.eulerAngles - rota; _rigid = TargetAtom.rigidbodies.First(rb => rb.name == link[1]); var newPosi = _rigid.transform.TransformPoint(localPosi); var newRota = _rigid.transform.rotation.eulerAngles - localRota; cuaControl.transform.position = newPosi; cuaControl.transform.rotation = Quaternion.Euler(newRota); /* Atom newEmpty = SuperController.singleton.GetAtomByUid("Empty"); newEmpty.GetStorableByID("control").transform.position = _rigid.transform.position; newEmpty.GetStorableByID("control").transform.rotation = _rigid.transform.rotation; */ //emptyControl.transform.position = _rigid.transform.position; //emptyControl.transform.rotation = _rigid.transform.rotation; } else { targetPosi = sourcePositionDic["control"] + sourcePositionDic[link[1]]; targetRota = sourceRotationDic["control"] + sourceRotationDic[link[1]]; emptyControl.transform.position = targetPosi; emptyControl.transform.rotation = Quaternion.Euler(targetRota); cuaControl.transform.position = posi; cuaControl.transform.rotation = Quaternion.Euler(rota); localPosi = emptyControl.transform.InverseTransformPoint(posi); localRota = emptyControl.transform.rotation.eulerAngles - rota; var newPosi = TargetAtom.GetStorableByID(link[1]).transform.TransformPoint(localPosi); var newRota = TargetAtom.GetStorableByID(link[1]).transform.rotation.eulerAngles - localRota; cuaControl.transform.position = newPosi; cuaControl.transform.rotation = Quaternion.Euler(newRota); //emptyControl.transform.position = TargetAtom.GetStorableByID(link[1]).transform.position; //emptyControl.transform.rotation = TargetAtom.GetStorableByID(link[1]).transform.rotation; } empty.Remove(); linkToAtom = SuperController.singleton.RigidbodyNameToRigidbody(TargetAtom.name + ":" + link[1]); cuaControl.SelectLinkToRigidbody(linkToAtom, FreeControllerV3.SelectLinkState.PositionAndRotation); if (tempAsObject["positionState"] != null) { cuaControl.currentPositionState = PosiST[tempAsObject["positionState"]]; } else { cuaControl.currentPositionState = PosiST["On"]; } if (tempAsObject["rotationState"] != null) { cuaControl.currentRotationState = RotaST[tempAsObject["rotationState"]]; } else { cuaControl.currentRotationState = RotaST["On"]; } yield return new WaitForSeconds(1f); } } else if (item != "position" && item != "rotation" && item != "positionState" && item != "rotationState") { if (cuaControl.GetBoolJSONParam(item) != null) { cuaControl.GetBoolJSONParam(item).val = bool.Parse(tempAsObject[item]); } else if (cuaControl.GetFloatJSONParam(item) != null) { cuaControl.GetFloatJSONParam(item).val = float.Parse(tempAsObject[item]); } else if (cuaControl.GetStringChooserJSONParam(item) != null) { cuaControl.GetStringChooserJSONParam(item).val = tempAsObject[item]; } else if (cuaControl.GetStringJSONParam(item) != null) { cuaControl.GetStringJSONParam(item).val = tempAsObject[item]; } } } } } addedCUA.GetStorableByID("control").GetBoolJSONParam("canGrabPosition").val = true; addedCUA.GetStorableByID("control").GetBoolJSONParam("canGrabRotation").val = true; if (cuaPluginPreset["setUnlistedParamsToDefault"] != null) { if (addedCUA.GetStorableByID("Preset").GetStringJSONParam("presetName").val == "") { string savePath = "Custom/Atom/CustomUnityAsset/"; string saveFile = "pluginPreset_by_AppearanceLoader_"; var loadFiles = reload.Replace("\\", "/").Split('/'); string time = DateTime.UtcNow.ToString().Replace("/", "_").Replace(":", "_"); var loadFile = loadFiles[loadFiles.Count() - 1].Replace(".json", "") + "_" + addedCUA.name + "_" + time; SaveJSON(cuaPluginPreset, savePath + "Preset_" + saveFile + loadFile + ".vap"); addedCUA.GetStorableByID("Preset").GetStringJSONParam("presetName").val = saveFile + loadFile; addedCUA.GetStorableByID("Preset").CallAction("MergeLoadPreset"); if (deletePluginPreset_Bool.val) { addedCUA.GetStorableByID("Preset").GetStringJSONParam("presetName").val = ""; FileManagerSecure.DeleteFile(savePath + "Preset_" + saveFile + loadFile + ".vap"); } } } addedCUA.GetBoolJSONParam("on").val = true; } } } } SuperController.singleton.SelectController(TargetAtom.mainController); } private void loadPlugin() { if (plugin_Bool.val) { if (pluginPreset["setUnlistedParamsToDefault"] != null) { string savePath = "Custom/Atom/Person/Plugins/"; string saveFile = "pluginPreset_by_AppearanceLoader_"; var loadFiles = reload.Replace("\\", "/").Split('/'); string time = DateTime.UtcNow.ToString().Replace("/", "_").Replace(":", "_"); var loadFile = loadFiles[loadFiles.Count() - 1].Replace(".json", "") + "_" + TargetAtom.name + "_" + time; SaveJSON(pluginPreset, savePath + "Preset_" + saveFile + loadFile + ".vap"); TargetAtom.GetStorableByID("PluginPresets").GetStringJSONParam("presetName").val = saveFile + loadFile; TargetAtom.GetStorableByID("PluginPresets").CallAction("MergeLoadPreset"); if (deletePluginPreset_Bool.val) { TargetAtom.GetStorableByID("PluginPresets").GetStringJSONParam("presetName").val = ""; FileManagerSecure.DeleteFile(savePath + "Preset_" + saveFile + loadFile + ".vap"); } } } } private string checkVar(string varFilename) { if (varFilename != "") { if (varFilename.Contains(".") && varFilename.Contains(":")) { string[] tempFilename = varFilename.Split(':'); string[] splitFilename = tempFilename[0].Split('.'); int ver = splitFilename.Count(); string tempName = ""; string reternName = ""; for (int i = 0; i < ver - 1; i++) { tempName = tempName + splitFilename[i] + "."; } string filenameVar; int varVer = 0; for (int k = 0; k < 100; k++) { filenameVar = "AddonPackages/" + tempName + k.ToString() + ".var"; if (FileManagerSecure.FileExists(filenameVar)) { varVer = k; } } if (varVer == 0) { for (int k = 0; k < 100; k++) { filenameVar = "AddonPackages/AddonPackages/" + tempName + k.ToString() + ".var"; if (FileManagerSecure.FileExists(filenameVar)) { varVer = k; } } } if (varVer == 0) { ArrayList allFiles = new ArrayList(); SearchFile("AddonPackages", tempName + "*.var", ref allFiles); var searchedFiles = (string[])allFiles.ToArray(typeof(string)); List varFiles = new List(); if (searchedFiles != null) { foreach (var item in searchedFiles) { var searchedFilesSplit = item.Replace("\\", "/").Split('/'); var searchedVarName = searchedFilesSplit[searchedFilesSplit.Length - 1]; searchedVarName = searchedVarName.Remove(searchedVarName.LastIndexOf(".var")); varFiles.Add(searchedVarName); } if (varFiles.Contains(tempFilename[0])) { var itemSplit = tempFilename[0].Split('.'); varVer = int.Parse(itemSplit[2]); } else { int latest = 1; foreach (var item in varFiles) { var itemSplit = item.Split('.'); if (latest <= int.Parse(itemSplit[2])) { latest = int.Parse(itemSplit[2]); } } varVer = latest; } } else { varVer = 0; } } if (varVer != 0) { reternName = tempName + varVer.ToString() + ":" + tempFilename[1]; if (reternName != varFilename) { //SuperController.LogMessage("Change var number"); //SuperController.LogMessage("from " + varFilename); //SuperController.LogMessage("to " + reternName); //SuperController.LogMessage(""); } return reternName; } } } return varFilename; } private string checkPath(string url) { string temp = url; if (url != "") { if (FileManagerSecure.FileExists(temp)) { return temp; } else if (temp.Contains(".") && temp.Contains(":")) { string[] tempFilename = temp.Split(':'); string[] splitFilename = tempFilename[0].Split('.'); int ver = splitFilename.Count(); string tempName = ""; string returnName = ""; for (int i = 0; i < ver - 1; i++) { tempName = tempName + splitFilename[i] + "."; } for (int k = 1; k < 100; k++) { returnName = tempName + k.ToString() + ":" + tempFilename[1]; if (FileManagerSecure.FileExists(returnName)) { return returnName; } } } if (temp.Substring(0, 5) == "SELF:") { temp = SELF + temp.Substring(4); } else if (temp.Contains(":")) { if (temp.IndexOf(":") != 1) { temp = checkVar(url); } } else if (temp.Substring(0, 9) == "Textures/") { temp = "Custom/Atom/Person/" + temp; } else if (!temp.Contains("/")) { temp = loadDir + temp; } else if (!(temp.Substring(0, 7) == "Custom/") && !(temp.Substring(0, 6) == "Saves/")) { if (!FileManagerSecure.FileExists(temp)) { temp = loadDir + temp; } } if (temp.IndexOf(":") != 1) { if (!FileManagerSecure.FileExists(temp)) { temp = ""; missingItem.val = missingItem.val + "\nMissing: " + url; } } //SuperController.LogMessage(temp); } return temp; } public static void SearchFile(string folder, string filter, ref ArrayList allFiles) { string[] filses = FileManagerSecure.GetFiles(folder, filter); allFiles.AddRange(filses); string[] subFolders = FileManagerSecure.GetDirectories(folder); foreach (string subF in subFolders) { SearchFile(subF, filter, ref allFiles); } } private void display(string word, Vector3 point) { word = word + " " + (point.x % 360).ToString() + ", "; word = word + (point.y % 360).ToString() + ", "; word = word + (point.z % 360).ToString(); SuperController.LogMessage(word); } void Start() { UpdateInitialMorphs(); } private void UpdateInitialMorphs() { JSONStorable geometry = TargetAtom.GetStorableByID("geometry"); DAZCharacterSelector character = geometry as DAZCharacterSelector; GenerateDAZMorphsControlUI morphControl = character.morphsControlUI; } #endregion public void OnDisable() { } public void OnDestroy() { } } }