Exemplo n.º 1
0
 public DeviceCurveEditorSettings(string name, UICurveEditor editor, JSONStorableAnimationCurve storable, Vector2 offset = new Vector2())
 {
     _name     = name;
     _editor   = editor;
     _storable = storable;
     _offset   = offset;
 }
Exemplo n.º 2
0
        public UICurveEditor CreateCurveEditor(float height, bool rightSide = false)
        {
            var container = CreateSpacer(height, rightSide);

            UICurveEditor curveEditor = null;
            var           buttons     = Enumerable.Range(0, 4)
                                        .Select(_ => UnityEngine.Object.Instantiate(UIManager.ConfigurableButtonPrefab))
                                        .Select(t => t.GetComponent <UIDynamicButton>())
                                        .ToList();

            foreach (var b in buttons)
            {
                b.buttonText.fontSize = 18;
                b.buttonColor         = Color.white;
            }

            buttons[0].label = "Mode";
            buttons[1].label = "In Mode";
            buttons[2].label = "Out Mode";
            buttons[3].label = "Linear";

            buttons[0].button.onClick.AddListener(() => curveEditor.ToggleHandleMode());
            buttons[1].button.onClick.AddListener(() => curveEditor.ToggleInHandleMode());
            buttons[2].button.onClick.AddListener(() => curveEditor.ToggleOutHandleMode());
            buttons[3].button.onClick.AddListener(() => curveEditor.SetLinear());

            curveEditor = new UICurveEditor(container, 510, height, buttons: buttons);
            curveEditor.settings.allowViewDragging = false;
            curveEditor.settings.allowViewScaling  = false;
            curveEditor.settings.allowViewZooming  = false;
            curveEditor.settings.showScrubbers     = true;
            return(curveEditor);
        }
Exemplo n.º 3
0
        public JSONStorableAnimationCurve CreateCurve(string paramName, UICurveEditor curveEditor, IEnumerable <Keyframe> keyframes = null)
        {
            var storable = _builder.CreateCurve(paramName, curveEditor, keyframes);

            _objects.Add(storable);
            return(storable);
        }
Exemplo n.º 4
0
        public JSONStorableAnimationCurve CreateCurve(string paramName, UICurveEditor curveEditor, IEnumerable <Keyframe> keyframes = null)
        {
            var storable = new JSONStorableAnimationCurve(paramName);

            if (keyframes != null)
            {
                storable.val = new AnimationCurve(keyframes.ToArray());
                storable.SetDefaultFromCurrent();
            }

            curveEditor.AddCurve(storable);
            return(storable);
        }
Exemplo n.º 5
0
        private void CreateA2AxisUI(IUIBuilder builder)
        {
            var group   = new UIGroup(builder);
            var visible = false;

            A2AxisTitle = builder.CreateButton("Lube | A2", () =>
            {
                group.SetVisible(visible = !visible);
                OutputA2CurveEditorSettings.SetVisible(visible);
            }, new Color(0.4f, 0.4f, 0.4f), Color.white, true);
            OutputA2CurveEditor = group.CreateCurveEditor(300, true);
            OutputA2Curve       = group.CreateCurve("Device:A2:OutputCurve", OutputA2CurveEditor, new List <Keyframe> {
                new Keyframe(0, 0, 0, 1), new Keyframe(1, 1, 1, 0)
            });
            OutputA2CurveEditor.SetDrawScale(OutputA2Curve, Vector2.one, Vector2.zero, true);

            OutputA2CurveEditorSettings = new DeviceCurveEditorSettings("A2:OutputCurveSettings", OutputA2CurveEditor, OutputA2Curve);
            OutputA2CurveEditorSettings.CreateUI(group);

            EnableOverrideA2Toggle = group.CreateToggle("Device:A2:EnableOverride", "Enable Override", true, true);
            OverrideA2Slider       = group.CreateSlider("Device:A2:Override", "Override Value (%)", 0f, 0f, 1f, true, true, true, "P0");

            group.SetVisible(false);
        }
Exemplo n.º 6
0
        public void CreateUI()
        {
            pluginLabelJSON.val = PluginName;

            var container = CreateSpacer();

            container.height = 300;

            var curveEditorButtons = Enumerable.Range(0, 4)
                                     .Select(_ => UnityEngine.Object.Instantiate(manager.configurableButtonPrefab))
                                     .Select(t => t.GetComponent <UIDynamicButton>())
                                     .ToList();

            foreach (var b in curveEditorButtons)
            {
                b.buttonText.fontSize = 18;
                b.buttonColor         = Color.white;
            }

            curveEditorButtons[0].label = "Mode";
            curveEditorButtons[1].label = "In Mode";
            curveEditorButtons[2].label = "Out Mode";
            curveEditorButtons[3].label = "Linear";

            curveEditorButtons[0].button.onClick.AddListener(() => _curveEditor.ToggleHandleMode());
            curveEditorButtons[1].button.onClick.AddListener(() => _curveEditor.ToggleInHandleMode());
            curveEditorButtons[2].button.onClick.AddListener(() => _curveEditor.ToggleOutHandleMode());
            curveEditorButtons[3].button.onClick.AddListener(() => _curveEditor.SetLinear());

            _curveEditor = new UICurveEditor(container, 520, container.height, buttons: curveEditorButtons);
            _curveEditor.AddCurve(_curve1JSON, UICurveLineColors.CreateFrom(new Color(0.388f, 0.698f, 0.890f)));
            _curveEditor.SetValueBounds(_curve1JSON, new Rect(0, 0, 2, 10), true, true);
            _curveEditor.AddCurve(_curve2JSON, UICurveLineColors.CreateFrom(new Color(0.890f, 0.388f, 0.398f)));
            _curveEditor.SetValueBounds(_curve2JSON, new Rect(0, 0, 2, 1), true, true);

            var resetButton = CreateButton("Reset");
            var playButton  = CreateButton("Play");
            var stopButton  = CreateButton("Stop");
            var fitButton   = CreateButton("Fit View");

            resetButton.button.onClick.AddListener(() =>
            {
                _curve1JSON.SetValToDefault();
                _curveEditor.UpdateCurve(_curve1JSON);
                _curve2JSON.SetValToDefault();
                _curveEditor.UpdateCurve(_curve2JSON);
            });
            playButton.button.onClick.AddListener(() =>
            {
                _animation.Play("CurveEditorDemo");
            });
            stopButton.button.onClick.AddListener(() =>
            {
                _animation.Stop();
            });
            fitButton.button.onClick.AddListener(() =>
            {
                _curveEditor.SetViewToFit(new Vector4(0.2f, 1, 0.2f, 1));
            });

            var readOnlyStorable = new JSONStorableBool("ReadOnly", false);
            var readOnlyToggle   = CreateToggle(readOnlyStorable);

            readOnlyStorable.setCallbackFunction = v => _curveEditor.readOnly = v;

            var showScrubberStorable = new JSONStorableBool("Show Scrubbers", true);
            var showScrubberToggle   = CreateToggle(showScrubberStorable);

            showScrubberStorable.setCallbackFunction = v => _curveEditor.showScrubbers = v;

            var scrubberSliderStorable = new JSONStorableFloat("Scrubber time", 0, 0, 2);
            var scrubberSlider         = CreateSlider(scrubberSliderStorable);

            scrubberSliderStorable.setCallbackFunction = v =>
            {
                var state = _animation["CurveEditorDemo"];
                if (state != null)
                {
                    state.time = v;
                }
                _curveEditor.SetScrubber(_curve1JSON, v);
                _curveEditor.SetScrubber(_curve2JSON, 2 - v);
            };

            var normalizeScaleStorable = new JSONStorableBool("Normalize to view", false);
            var normalizeScaleToggle   = CreateToggle(normalizeScaleStorable);

            var offsetScaleStorable = new JSONStorableBool("Offset to center", false);
            var offsetScaleToggle   = CreateToggle(offsetScaleStorable);

            var timeScaleSliderStorable  = new JSONStorableFloat("Time Scale", 1, 0.5f, 8);
            var valueScaleSliderStorable = new JSONStorableFloat("Value Scale", 1, 0.5f, 8);

            var timeScaleSlider = CreateSlider(timeScaleSliderStorable);

            timeScaleSliderStorable.setCallbackFunction = v =>
            {
                _curveEditor.SetValueBounds(_curve1JSON, new Rect(0, 0, v, valueScaleSliderStorable.val), normalizeScaleStorable.val, offsetScaleStorable.val);
                _curveEditor.SetValueBounds(_curve2JSON, new Rect(0, 0, v, valueScaleSliderStorable.val), normalizeScaleStorable.val, offsetScaleStorable.val);
            };

            var valueScaleSlider = CreateSlider(valueScaleSliderStorable);

            valueScaleSliderStorable.setCallbackFunction = v =>
            {
                _curveEditor.SetValueBounds(_curve1JSON, new Rect(0, 0, timeScaleSliderStorable.val, v), normalizeScaleStorable.val, offsetScaleStorable.val);
                _curveEditor.SetValueBounds(_curve2JSON, new Rect(0, 0, timeScaleSliderStorable.val, v), normalizeScaleStorable.val, offsetScaleStorable.val);
            };
        }
Exemplo n.º 7
0
        public void CreateUI()
        {
            pluginLabelJSON.val = PluginName;

            var container = CreateSpacer();

            container.height = 300;

            var curveEditorButtons = Enumerable.Range(0, 4)
                                     .Select(_ => UnityEngine.Object.Instantiate(manager.configurableButtonPrefab))
                                     .Select(t => t.GetComponent <UIDynamicButton>())
                                     .ToList();

            foreach (var b in curveEditorButtons)
            {
                b.buttonText.fontSize = 18;
                b.buttonColor         = Color.white;
            }

            curveEditorButtons[0].label = "Mode";
            curveEditorButtons[1].label = "In Mode";
            curveEditorButtons[2].label = "Out Mode";
            curveEditorButtons[3].label = "Linear";

            curveEditorButtons[0].button.onClick.AddListener(() => _curveEditor.ToggleHandleMode());
            curveEditorButtons[1].button.onClick.AddListener(() => _curveEditor.ToggleInHandleMode());
            curveEditorButtons[2].button.onClick.AddListener(() => _curveEditor.ToggleOutHandleMode());
            curveEditorButtons[3].button.onClick.AddListener(() => _curveEditor.SetLinear());

            _curveEditor = new UICurveEditor(container, 520, container.height, buttons: curveEditorButtons);
            _curveEditor.AddCurve(_curveJSON, UICurveLineColors.CreateFrom(new Color(0.388f, 0.698f, 0.890f)));
            _curveEditor.AddCurve(_curve2JSON, UICurveLineColors.CreateFrom(new Color(0.890f, 0.388f, 0.398f)));

            var resetButton = CreateButton("Reset");
            var playButton  = CreateButton("Play");
            var stopButton  = CreateButton("Stop");

            resetButton.button.onClick.AddListener(() =>
            {
                _curveJSON.SetValToDefault();
                _curveEditor.UpdateCurve(_curveJSON);
            });
            playButton.button.onClick.AddListener(() =>
            {
                _animation.Play("CurveEditorDemo");
            });
            stopButton.button.onClick.AddListener(() =>
            {
                _animation.Stop();
            });

            var readOnlyStorable = new JSONStorableBool("ReadOnly", false);
            var readOnlyToggle   = CreateToggle(readOnlyStorable);

            readOnlyStorable.setCallbackFunction = v => _curveEditor.readOnly = v;

            var showScrubberStorable = new JSONStorableBool("Show Scrubbers", true);
            var showScrubberToggle   = CreateToggle(showScrubberStorable);

            showScrubberStorable.setCallbackFunction = v => _curveEditor.showScrubbers = v;

            var sliderStorable = new JSONStorableFloat("Scrubber time", 0, 0, 1);
            var slider         = CreateSlider(sliderStorable);

            sliderStorable.setCallbackFunction = v =>
            {
                _curveEditor.SetScrubber(_curveJSON, v);
                _curveEditor.SetScrubber(_curve2JSON, 1 - v);
            };
        }