public override void Init() { try { lastLoadPath = PATH_WHEN_LOADED = SuperController.singleton.currentLoadDir; sc = SuperController.singleton; DAZCharacterSelector dcs = containingAtom.GetStorableByID("geometry") as DAZCharacterSelector; morphControl = dcs.morphsControlUI; // Fix tongue morph... morphControl.GetMorphByDisplayName("Tongue In-Out").startValue = 0.0f; headAudioSource = containingAtom.GetStorableByID("HeadAudioSource") as AudioSourceControl; JSONStorableAction playRandomAction = new JSONStorableAction("Play Random Expression", () => { if (currentAnimation != null) { currentAnimation.Stop(); } if (animationLookup.Count == 0) { return; } ExpressionAnimation selectedAnimation = currentAnimation; do { int randomIndex = UnityEngine.Random.Range(0, animationLookup.Count); string key = animationLookup.Keys.ToList()[randomIndex]; selectedAnimation = animationLookup[key]; if (animationLookup.Count <= 1) { break; } }while (currentAnimation == selectedAnimation); PlayExpression(selectedAnimation); }); RegisterAction(playRandomAction); JSONStorableAction playRandomWhenReadyAction = new JSONStorableAction("Play Random Expression When Ready", () => { if (currentAnimation != null) { return; } if (animationLookup.Count == 0) { return; } ExpressionAnimation selectedAnimation = currentAnimation; do { int randomIndex = UnityEngine.Random.Range(0, animationLookup.Count); string key = animationLookup.Keys.ToList()[randomIndex]; selectedAnimation = animationLookup[key]; if (animationLookup.Count <= 1) { break; } }while (currentAnimation == selectedAnimation); PlayExpression(selectedAnimation); }); RegisterAction(playRandomWhenReadyAction); CreateButton("Load Expression").button.onClick.AddListener(() => { sc.fileBrowserUI.defaultPath = PATH_WHEN_LOADED; sc.fileBrowserUI.SetTextEntry(false); sc.fileBrowserUI.Show((path) => { if (string.IsNullOrEmpty(path)) { return; } JSONStorableString store = storeList.GetNext(); if (store == null) { return; } CreateUIFromExpressionPath(path, store); lastLoadPath = path; }); }); CreateButton("Load Expression (Folder)").button.onClick.AddListener(() => { sc.GetDirectoryPathDialog((path) => { if (string.IsNullOrEmpty(path)) { return; } sc.GetFilesAtPath(path).ToList().ForEach((filePath) => { if (filePath.ToLower().Contains(".json") == false) { return; } JSONStorableString store = storeList.GetNext(); if (store == null) { return; } Debug.Log("loading " + filePath); CreateUIFromExpressionPath(filePath, store); }); lastLoadPath = path; }, lastLoadPath); }); CreateButton("Secret Button", true); CreateButton("Clear All", true).button.onClick.AddListener(() => { uiList.GetRange(0, uiList.Count).ForEach((ui) => { ui.Remove(); }); }); CreateSpacer(false).height = 50; CreateSpacer(true).height = 50; // do this last so it shows up at the bottom... storeList = new StorableStringList(this, "expression_"); } catch (Exception e) { SuperController.LogError("Exception caught: " + e); } }