public override void Init() { try { if (containingAtom.type != "Person") { SuperController.LogError($"Requires atom of type person, instead selected: {containingAtom.type}"); return; } JSONStorable geometry = containingAtom.GetStorableByID("geometry"); DAZCharacterSelector dcs = geometry as DAZCharacterSelector; GenerateDAZMorphsControlUI morphUI = dcs.morphsControlUI; if (morphUI != null) { eyesClosed = morphUI.GetMorphByDisplayName("Eyes Closed"); } JSONStorable eyelids = containingAtom.GetStorableByID("EyelidControl"); autoBlink = eyelids.GetBoolJSONParam("blinkEnabled"); } catch (System.Exception e) { SuperController.LogError("Exception caught: " + e); } }
private void SaveStorable(JSONStorable aStorable, out JsonDict aDict) { aDict = new JsonDict(); foreach (var param in aStorable.GetAllFloatAndColorParamNames()) { var type = aStorable.GetParamOrActionType(param); JSONClass json = new JSONClass(); json["type"] = type.ToString(); json["id"] = param; JSONClass storableParams = new JSONClass(); switch (type) { case JSONStorable.Type.Color: aStorable.GetColorJSONParam(param)?.StoreJSON(storableParams); break; case JSONStorable.Type.Float: aStorable.GetFloatJSONParam(param)?.StoreJSON(storableParams); break; case JSONStorable.Type.Bool: aStorable.GetBoolJSONParam(param)?.StoreJSON(storableParams); break; case JSONStorable.Type.String: aStorable.GetStringJSONParam(param)?.StoreJSON(storableParams); break; case JSONStorable.Type.StringChooser: aStorable.GetStringChooserJSONParam(param)?.StoreJSON(storableParams); break; default: SuperController.LogError("Unhandled type: " + type.ToString()); break; } json["params"] = storableParams; aDict[param] = json; } }
private void RestoreStorable(JSONStorable aStorable, JsonDict aDict, List <string> aRestoreList = null) { foreach (var kp in aDict) { JSONClass json = kp.Value; string param = kp.Key; if (aRestoreList != null && !aRestoreList.Contains(param)) { continue; } JSONStorable.Type type = (JSONStorable.Type)Enum.Parse(typeof(JSONStorable.Type), json["type"].Value); JSONClass paramJson = json["params"].AsObject; switch (type) { case JSONStorable.Type.Color: aStorable.GetColorJSONParam(param)?.RestoreFromJSON(paramJson); break; case JSONStorable.Type.Float: aStorable.GetFloatJSONParam(param)?.RestoreFromJSON(paramJson); break; case JSONStorable.Type.Bool: aStorable.GetBoolJSONParam(param)?.RestoreFromJSON(paramJson); break; case JSONStorable.Type.String: aStorable.GetStringJSONParam(param)?.RestoreFromJSON(paramJson); break; case JSONStorable.Type.StringChooser: aStorable.GetStringChooserJSONParam(param)?.RestoreFromJSON(paramJson); break; default: SuperController.LogError("Unhandled type: " + type.ToString()); break; } } }