コード例 #1
0
    void Update()
    {
        if (button != null)
        {
            bool buttonEnabled = button.controlEnabled;

            if (buttonGraphic != null)
            {
                Color targetButtonColor = buttonGraphicColor;
                if (button.isPressed)
                {
                    targetButtonColor = buttonDepressedColor;
                }
                if (!buttonEnabled)
                {
                    targetButtonColor = buttonDisabledColor;
                }
                targetButtonColor = targetButtonColor.Multiply(buttonTint);
                if (!buttonEnabled)
                {
                    targetButtonColor = Color.Lerp(targetButtonColor, buttonDisabledColor, 0.5F);
                }

                buttonGraphic.SetRuntimeTint(targetButtonColor);
            }
        }
    }
コード例 #2
0
    private void refreshColor()
    {
        if (palette == null)
        {
            return;
        }
        if (graphic == null)
        {
            return;
        }

        Color color = palette.colors[colorIndex];

        var text = graphic as LeapTextGraphic;

        if (text != null)
        {
            text.color = color;
        }
        else
        {
            try { graphic.SetRuntimeTint(color); }
            catch (System.Exception) { }
        }
    }
コード例 #3
0
        private void setColor(Color color)
        {
            var text = graphic as LeapTextGraphic;

            if (text != null)
            {
                text.color = color;
            }
            else
            {
                if (graphic != null)
                {
                    graphic.SetRuntimeTint(color);
                }
                else
                {
                    if (renderer != null)
                    {
                        if (Application.isPlaying)
                        {
                            renderer.material.SetColor(_shaderColorID, color);
                        }
                        else
                        {
                            renderer.sharedMaterial.SetColor(_shaderColorID, color);
                        }
                    }
                }
            }
        }
コード例 #4
0
    void Update()
    {
        if (toggle != null)
        {
            bool toggleEnabled = toggle.controlEnabled;

            if (toggleGraphic != null)
            {
                Color targetToggleColor = toggle.isToggled ? toggledColor : untoggledColor;
                if (toggle.isPressed)
                {
                    targetToggleColor = depressedColor;
                }
                if (!toggleEnabled)
                {
                    targetToggleColor = disabledColor;
                }
                targetToggleColor = targetToggleColor.Multiply(toggleTint);
                if (!toggleEnabled)
                {
                    targetToggleColor = Color.Lerp(targetToggleColor, disabledColor, 0.5F);
                }

                toggleGraphic.SetRuntimeTint(targetToggleColor);
            }
        }
    }
コード例 #5
0
    private void setColor(Color color)
    {
        var text = graphic as LeapTextGraphic;

        if (text != null)
        {
            text.color = color;
        }
        else
        {
            graphic.SetRuntimeTint(color);
        }
    }
コード例 #6
0
        void Update()
        {
#if LeapGraphicRenderer
            if (_graphic != null)
            {
                // The target color for the Interaction object will be determined by various simple state checks.
                Color targetColor = defaultColor;

                // "Primary hover" is a special kind of hover state that an InteractionBehaviour can
                // only have if an InteractionHand's thumb, index, or middle finger is closer to it
                // than any other interaction object.
                if (_intObj.isPrimaryHovered && usePrimaryHover)
                {
                    targetColor = primaryHoverColor;
                }
                else
                {
                    // Of course, any number of objects can be hovered by any number of InteractionHands.
                    // InteractionBehaviour provides an API for accessing various interaction-related
                    // state information such as the closest hand that is hovering nearby, if the object
                    // is hovered at all.
                    if (_intObj.isHovered && useHover)
                    {
                        float glow = _intObj.closestHoveringControllerDistance.Map(0F, 0.2F, 1F, 0.0F);
                        targetColor = Color.Lerp(defaultColor, hoverColor, glow);
                    }
                }

                if (_intObj.isSuspended)
                {
                    // If the object is held by only one hand and that holding hand stops tracking, the
                    // object is "suspended." InteractionBehaviour provides suspension callbacks if you'd
                    // like the object to, for example, disappear, when the object is suspended.
                    // Alternatively you can check "isSuspended" at any time.
                    targetColor = suspendedColor;
                }

                // We can also check the depressed-or-not-depressed state of InteractionButton objects
                // and assign them a unique color in that case.
                if (_intObj is InteractionButton && (_intObj as InteractionButton).isPressed)
                {
                    targetColor = pressedColor;
                }

                // Lerp actual material color to the target color.
                _graphic.SetRuntimeTint(Color.Lerp(_graphic.GetRuntimeTint(), targetColor, 30F * Time.deltaTime));
            }
#endif
        }
コード例 #7
0
    void Update()
    {
        if (slider != null)
        {
            bool sliderEnabled = slider.controlEnabled;

            if (panelGraphic != null)
            {
                Color targetPanelColor = panelGraphicColor;
                if (slider.isPressed)
                {
                    targetPanelColor = panelDepressedColor;
                }
                if (!sliderEnabled)
                {
                    targetPanelColor = panelDisabledColor;
                }
                targetPanelColor = targetPanelColor.Multiply(panelTint);
                if (!sliderEnabled)
                {
                    targetPanelColor = Color.Lerp(targetPanelColor, panelDisabledColor, 0.5F);
                }

                panelGraphic.SetRuntimeTint(targetPanelColor);
            }

            if (sliderGraphic != null)
            {
                Color targetSliderColor = sliderGraphicColor;
                if (slider.isPressed)
                {
                    targetSliderColor = sliderDepressedColor;
                }
                if (!sliderEnabled)
                {
                    targetSliderColor = sliderDisabledColor;
                }
                targetSliderColor = targetSliderColor.Multiply(sliderTint);
                if (!sliderEnabled)
                {
                    targetSliderColor = Color.Lerp(targetSliderColor, sliderDisabledColor, 0.5F);
                }

                sliderGraphic.SetRuntimeTint(targetSliderColor);
            }
        }
    }
コード例 #8
0
        void Update()
        {
            var color = graphic.GetRuntimeTint();

            var sqrColorDist = getSqrColorDist(color, _targetColor);

            if (sqrColorDist == 0f)
            {
                return;
            }
            else if (sqrColorDist < 0.01f * 0.01f)
            {
                color = _targetColor;
            }
            else
            {
                color = Color.Lerp(color, _targetColor, colorChangeSpeed * Time.deltaTime);
            }

            graphic.SetRuntimeTint(color);
        }