public override void OnGUI()
        {
            var r = _color.r;
            var g = _color.g;
            var b = _color.b;
            var a = _color.a;

            GUI.Label(_labelR, "r");
            GUI.Label(_labelG, "g");
            GUI.Label(_labelB, "b");
            GUI.Label(_labelA, "a");

            r = GUI.HorizontalSlider(_sliderR, r, 0f, 1f);
            g = GUI.HorizontalSlider(_sliderG, g, 0f, 1f);
            b = GUI.HorizontalSlider(_sliderB, b, 0f, 1f);
            a = GUI.HorizontalSlider(_sliderA, a, 0f, 1f);

            var rChanged = UpdateDirectInput(_inputSocketR, _color.r, r);
            var gChanged = UpdateDirectInput(_inputSocketG, _color.g, g);
            var bChanged = UpdateDirectInput(_inputSocketB, _color.b, b);
            var aChanged = UpdateDirectInput(_inputSocketA, _color.a, a);

            if (rChanged || gChanged || bChanged || aChanged)
            {
                SetColor(r, g, b, a);
                TriggerChangeEvent();
            }

            NodeUtils.GUIDrawRect(new Rect(77, 0, 20, 20), _color);
        }
Beispiel #2
0
        protected override void OnGUI()
        {
            GUI.skin.label.alignment = TextAnchor.MiddleLeft;
            var r = _color.r;
            var g = _color.g;
            var b = _color.b;
            var a = _color.a;

            _sliderR = new Rect(18, 0, Width - 45, 20);
            _sliderG = new Rect(18, 20, Width - 45, 20);
            _sliderB = new Rect(18, 40, Width - 45, 20);
            _sliderA = new Rect(18, 60, Width - 45, 20);

            bool wasMouseUp = Event.current.type == EventType.MouseUp;

            GUI.Label(_labelR, "r");
            GUI.Label(_labelG, "g");
            GUI.Label(_labelB, "b");
            GUI.Label(_labelA, "a");

            r = GUI.HorizontalSlider(_sliderR, (float)Math.Round(r, 3), 0f, 1f);
            g = GUI.HorizontalSlider(_sliderG, (float)Math.Round(g, 3), 0f, 1f);
            b = GUI.HorizontalSlider(_sliderB, (float)Math.Round(b, 3), 0f, 1f);
            a = GUI.HorizontalSlider(_sliderA, (float)Math.Round(a, 3), 0f, 1f);

            var rChanged = UpdateDirectInput(_inputSocketR, _color.r, r);
            var gChanged = UpdateDirectInput(_inputSocketG, _color.g, g);
            var bChanged = UpdateDirectInput(_inputSocketB, _color.b, b);
            var aChanged = UpdateDirectInput(_inputSocketA, _color.a, a);

            if (rChanged || gChanged || bChanged || aChanged)
            {
                SetColor(r, g, b, a);
            }

            if (wasMouseUp && Event.current.type == EventType.Used)
            {
                TriggerChangeEvent();
            }

            NodeUtils.GUIDrawRect(new Rect(Width - 22, 0, 20, Height - 25), _color);
            GUI.skin.label.alignment = TextAnchor.MiddleCenter;
        }