protected Color getColor() { if (graphic != null) { var text = graphic as LeapTextGraphic; if (text != null) { return(text.color); } else { return(graphic.GetRuntimeTint()); } } else { if (Application.isPlaying) { return(renderer.material.GetColor(_shaderColorID)); } else { return(renderer.sharedMaterial.GetColor(_shaderColorID)); } } }
protected Color getColor() { var text = graphic as LeapTextGraphic; if (text != null) { return(text.color); } else { return(graphic.GetRuntimeTint()); } }
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 }
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); }