public void Init(MVRScript plugin, string mainScreen) { _mainScreenName = mainScreen; _backButton = plugin.CreateButton("< Back"); _backButton.button.onClick.AddListener(() => Show(mainScreen)); _backButton.height = 100f; }
public PluginReference(MVRScript plugin) { _plugin = plugin; _selectButton = plugin.CreateButton("Browse..."); _labelJSON.setCallbackFunction = val => _selectButton.label = string.IsNullOrEmpty(_labelJSON.val) ? "Browse..." : _labelJSON.val; _pluginJSON.beginBrowseWithObjectCallback = jsu => { jsu.shortCuts = FileManagerSecure.GetShortCutsForDirectory("Custom/Scripts", true, true, true, true); }; _pluginJSON.setCallbackFunction = val => { if (string.IsNullOrEmpty(val)) { return; } SyncLabel(val); onChange.Invoke(); }; _pluginJSON.fileBrowseButton = _selectButton.button; _removeButton = plugin.CreateButton("Remove", true); _removeButton.button.onClick.AddListener(() => onRemove.Invoke()); _removeButton.textColor = Color.white; _removeButton.buttonColor = Color.red; }
protected void CreateControls() { DestroyControls(); /* * var debugJson = new JSONStorableString("Debug", Id); * RegisterStorable(debugJson); * var debugTextField = Script.CreateTextField(debugJson, true); * debugTextField.height = 80f; * var debugTextInputField = debugTextField.gameObject.AddComponent<UnityEngine.UI.InputField>(); * debugTextInputField.textComponent = debugTextField.UItext; * debugJson.inputField = debugTextInputField; * RegisterControl(debugTextField); */ if (IsDuplicate) { var jss = RegisterStorable(new JSONStorableString("Duplicate", "This item has duplicates and cannot be edited.")); RegisterControl(Script.CreateTextField(jss)); } else { _modifiedJson = new JSONStorableBool("This item has been modified", false); _modifiedJson.valNoCallback = Modified; _modifiedJson.setCallbackFunction = (bool val) => { if (val) { // You cannot just enable the Modified flag without actually modifying anything _modifiedJson.valNoCallback = false; return; } ResetToInitial(); }; var resetUi = Script.CreateToggle(_modifiedJson, true); RegisterControl(resetUi); if (Mirror != null) { var goToMirrorButton = Script.CreateButton("Go to mirror", true); goToMirrorButton.button.onClick.AddListener(() => { Script.SendMessage("SelectEditable", Mirror); }); RegisterControl(goToMirrorButton); } CreateControlsInternal(); } }
public ActionSelector( MVRScript plug, CallbackAction call = null, string name = "action", string startAtom = null, AtomStorableSelector _storableSelected = null) : base(call) { try { actionButton = plug.CreateButton(null, true); actionButton.button.onClick.AddListener(CallAction); //actionButton.button.gameObject.SetActive(false); actionButton.button.enabled = false; skipSaveRestore = new JSONStorableBool("skip saverestore", false); plug.RegisterBool(skipSaveRestore); if (_storableSelected == null) { storableSelected = new AtomStorableSelector(plug, SyncStorable, startAtom); } else { SuperController.LogMessage("..."); storableSelected = _storableSelected; storableSelected.Add(SyncStorable); } actionChooser = new JSONStorableStringChooser(name, null, null, name, SyncActionTarget); plug.RegisterStringChooser(actionChooser); UIDynamicPopup dp = plug.CreateScrollablePopup(actionChooser); dp.popupPanelHeight = 820f; plug.CreateToggle(skipSaveRestore).toggle.onValueChanged.AddListener( b => { if (storableSelected.storable != null && storableSelected.storable.name != "None") { SyncStorable(storableSelected.storable.name); } }); } catch (Exception e) { SuperController.LogError("Exception caught: " + e); } }
public void InitUI(MVRScript script, List <NamedAudioClip> nacs, JSONStorableString folderpath) { filetype = new JSONStorableStringChooser("File type", new List <string>(supportedFileTypes), ".wav", "File type", s => audiofilefilter.val = s); script.RegisterStringChooser(filetype); audiofilefilter = new JSONStorableString("audiofilefilter", ".wav"); lastLoadPath = DEFAULT_PATH; _path = folderpath; UIDynamicPopup popup = script.CreateScrollablePopup(filetype, false); popup.labelTextColor = Color.yellow; popup.popup.selectColor = Color.yellow; /*script.CreateButton("Load Audio (Folder)").button.onClick.AddListener( * () => OpenLoadFolder(nacs, lastLoadPath));*/ script.CreateButton("Remove all clips from scene audio").button.onClick.AddListener( () => URLAudioClipManager.singleton.RemoveAllClips()); // do it URLAudioClipManager.singleton.RemoveAllClips(); }
public UIDynamicButton CreateButton(string label, bool rightSide = false) { return(_buttons.AddAndReturn(_plugin.CreateButton(label, rightSide))); }
public static void Button(MVRScript script, string label, UnityEngine.Events.UnityAction handler, bool right = false) { script.CreateButton(label, right).button.onClick.AddListener(handler); }