protected void DestroyControls()
    {
        foreach (var storable in _controlsStorables)
        {
            if (storable is JSONStorableFloat)
            {
                var jsf = (JSONStorableFloat)storable;
                Script.RemoveSlider(jsf);
            }
            else if (storable is JSONStorableBool)
            {
                var jsb = (JSONStorableBool)storable;
                Script.RemoveToggle(jsb);
            }
            else if (storable is JSONStorableString)
            {
                var jss = (JSONStorableString)storable;
                Script.RemoveTextField(jss);
            }
            else
            {
                SuperController.LogError($"Unknown storable type: {storable.GetType()}");
            }
        }

        _controlsStorables.Clear();

        foreach (var control in _controlDynamics)
        {
            if (control is UIDynamicSlider)
            {
                var slider = (UIDynamicSlider)control;
                Script.RemoveSlider(slider);
            }
            else if (control is UIDynamicToggle)
            {
                var toggle = (UIDynamicToggle)control;
                Script.RemoveToggle(toggle);
            }
            else if (control is UIDynamicTextField)
            {
                var textfield = (UIDynamicTextField)control;
                Script.RemoveTextField(textfield);
            }
            else if (control is UIDynamicButton)
            {
                var button = (UIDynamicButton)control;
                Script.RemoveButton(button);
            }
            else
            {
                SuperController.LogError($"Unknown control type: {control.GetType()}");
            }
        }

        _controlDynamics.Clear();

        _modifiedJson = null;
    }
Example #2
0
    public void RemoveAll()
    {
        foreach (var section in _childSections)
        {
            section.RemoveAll();
        }
        _childSections.Clear();

        foreach (var toggle in _toggles)
        {
            _plugin.RemoveToggle(toggle);
        }
        _toggles.Clear();

        foreach (var slider in _sliders)
        {
            _plugin.RemoveSlider(slider);
        }
        _sliders.Clear();

        foreach (var popup in _popups)
        {
            popup.popup.visible = false;
            _plugin.RemovePopup(popup);
        }
        _popups.Clear();

        foreach (var button in _buttons)
        {
            _plugin.RemoveButton(button);
        }
        _buttons.Clear();

        foreach (var button in _textFields)
        {
            _plugin.RemoveTextField(button);
        }
        _textFields.Clear();

        foreach (var spacer in _spacers)
        {
            _plugin.RemoveSpacer(spacer);
        }
        _spacers.Clear();
    }