Example #1
0
        public FloatSelector(
            MVRScript plug, bool insideRestore,
            CallbackAction call,
            string startAtom = null,
            AtomStorableSelector _storableSelected = null)
        {
            try
            {
                currentValue = new JSONStorableFloat("current value", 0f, setValue, -1f, 1f, false);
                plug.RegisterFloat(currentValue);

                currentValueSlider = plug.CreateSlider(currentValue, true);
                currentValueSlider.gameObject.SetActive(false);

                this.insideRestore = insideRestore;
                if (_storableSelected == null)
                {
                    storableSelected = new AtomStorableSelector(plug, SyncStorable, startAtom);
                }
                else
                {
                    storableSelected = _storableSelected;
                    storableSelected.Add(SyncStorable);
                }

                floatChooser = new JSONStorableStringChooser("floatTarget", null, null, "Value", SyncfloatTarget);
                UIDynamicPopup dp = plug.CreateScrollablePopup(floatChooser);
                dp.popupPanelHeight = 820f;
                plug.RegisterStringChooser(floatChooser);
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }
Example #2
0
        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);
            }
        }