override public void UpdateUIComponents(Ray rCastRay, bool inputValid, Collider parentCollider)
        {
            bool bButtonsAvailable = m_CurrentPageFlipState == PageFlipState.Standard;

            //update sketch icons
            for (int i = 0; i < m_Icons.Length; ++i)
            {
                bool      bThisIconActive = false;
                ImageIcon rIcon           = m_Icons[i];

                if (bButtonsAvailable && rIcon.m_Valid &&
                    BasePanel.DoesRayHitCollider(rCastRay, rIcon.m_IconScript.GetCollider()))
                {
                    bool bWasButtonPressed = rIcon.m_IconScript.IsPressed();
                    rIcon.m_IconScript.UpdateButtonState(inputValid);
                    if (rIcon.m_IconScript.IsPressed() && !bWasButtonPressed)
                    {
                        //on press, refresh the buttons
                        RefreshPage();
                    }

                    bThisIconActive = true;
                }

                if (!bThisIconActive)
                {
                    //reset state of button because we're not messing with it
                    rIcon.m_IconScript.ResetState();
                }
            }

            base.UpdateUIComponents(rCastRay, inputValid, parentCollider);
        }
Beispiel #2
0
 // The forward out parameter is exposed so it can be modified by deriving components.
 virtual public bool CalculateReticleCollision(Ray ray, ref Vector3 pos, ref Vector3 forward) {
   RaycastHit hitInfo;
   if (BasePanel.DoesRayHitCollider(ray, GetCollider(), out hitInfo)) {
     pos = hitInfo.point;
     return true;
   }
   return false;
 }
 override public void HasFocus(RaycastHit hitInfo) {
   // If the trash is active and we're hovering over it, don't hide it.
   Ray hoverRay = new Ray(hitInfo.point - transform.forward, transform.forward);
   if (m_TrashButton.gameObject.activeSelf &&
       !BasePanel.DoesRayHitCollider(hoverRay, m_TrashButton.GetCollider())) {
     HideTrash();
   }
 }
 override public bool UpdateStateWithInput(bool inputValid, Ray inputRay,
       GameObject parentActiveObject, Collider parentCollider) {
   if (base.UpdateStateWithInput(inputValid, inputRay, parentActiveObject, parentCollider)) {
     if (parentActiveObject == null || parentActiveObject == gameObject) {
       if (BasePanel.DoesRayHitCollider(inputRay, GetCollider())) {
         m_UIComponentManager.UpdateUIComponents(inputRay, inputValid, parentCollider);
         return true;
       }
     }
   }
   return false;
 }
Beispiel #5
0
        override protected void OnButtonPressed()
        {
            Vector3 reticlePos = SketchControlsScript.m_Instance.GetUIReticlePos();
            Ray     reticleRay = new Ray(reticlePos - transform.forward, transform.forward);

            // Did we hit the scrub bar?
            m_ScrubBarHasFocus = BasePanel.DoesRayHitCollider(reticleRay, m_ScrubBar, true);
            if (!m_ScrubBarHasFocus)
            {
                // Nope.  Default behavior.
                base.OnButtonPressed();
            }
        }
Beispiel #6
0
        virtual public void CalculateReticleCollision(Ray castRay, ref Vector3 pos, ref Vector3 forward)
        {
            RaycastHit hitInfo;

            // Take a step back since the ray's origin could be on the surface of the popup.
            castRay.origin -= castRay.direction;
            if (BasePanel.DoesRayHitCollider(castRay, GetCollider(), out hitInfo))
            {
                pos = hitInfo.point;
            }

            m_UIComponentManager.CalculateReticleCollision(castRay, ref pos, ref forward);
        }
        override public void CalculateReticleCollision(Ray castRay, ref Vector3 pos, ref Vector3 forward)
        {
            RaycastHit rHitInfo;

            for (int i = 0; i < m_Icons.Length; ++i)
            {
                if (BasePanel.DoesRayHitCollider(castRay, m_Icons[i].m_IconScript.GetCollider(), out rHitInfo))
                {
                    pos = rHitInfo.point;
                    return;
                }
            }

            base.CalculateReticleCollision(castRay, ref pos, ref forward);
        }
Beispiel #8
0
    // Update this component with a flag signifying input to the parent panel is valid.
    // This is called by the parent and should return true if the parent should
    // update the active UI object to be this entity.
    virtual public bool UpdateStateWithInput(bool inputValid, Ray inputRay,
        GameObject parentActiveObject, Collider parentCollider) {
      if (parentActiveObject == null || parentActiveObject == gameObject || m_StealFocus) {
        RaycastHit rHitInfo;
        if (BasePanel.DoesRayHitCollider(inputRay, GetCollider(), out rHitInfo)) {
          if (!m_HadFocus) {
            GainFocus();
            m_HadFocus = true;
          } else {
            HasFocus(rHitInfo);
          }

          if (inputValid) {
            if (!m_HadButtonPress) {
              ButtonPressed(rHitInfo);
              m_HadButtonPress = true;
            } else {
              ButtonHeld(rHitInfo);
            }
          } else {
            if (m_HadButtonPress) {
              ButtonReleased();
              m_HadButtonPress = false;
            }
          }
          return true;
        } else {
          if (m_HadButtonPress) {
            if (inputValid && m_HoldFocus) {
              if (BasePanel.DoesRayHitCollider(inputRay, parentCollider, out rHitInfo)) {
                ButtonHeld(rHitInfo);
                return true;
              }
            } else {
              if (m_HoldFocus) {
                ButtonReleased();
              }
              m_HadButtonPress = false;
            }
          } else if (m_HadFocus) {
            LostFocus();
            m_HadFocus = false;
          }
        }
      }
      return false;
    }
Beispiel #9
0
        override public bool CalculateReticleCollision(
            Ray castRay, ref Vector3 pos, ref Vector3 forward)
        {
            //see if our cast direction hits the selector
            RaycastHit selectorHitInfo;
            RaycastHit sliderHitInfo;

            bool selectorValid = BasePanel.DoesRayHitCollider(castRay,
                                                              m_ColorPickerSelector.GetCollider(), out selectorHitInfo);
            bool sliderValid = BasePanel.DoesRayHitCollider(castRay,
                                                            m_ColorPickerSlider.GetCollider(), out sliderHitInfo);

            if (selectorValid && sliderValid)
            {
                // Find the one that's closest and disable the other.
                if ((selectorHitInfo.point - castRay.origin).sqrMagnitude <
                    (sliderHitInfo.point - castRay.origin).sqrMagnitude)
                {
                    sliderValid = false;
                }
                else
                {
                    selectorValid = false;
                }
            }

            // Custom transforms for colliding with an object.
            if (selectorValid)
            {
                pos     = selectorHitInfo.point;
                forward = -m_ColorPickerSelector.transform.forward;
                return(true);
            }
            else if (sliderValid)
            {
                pos     = sliderHitInfo.point;
                forward = -m_ColorPickerSlider.transform.forward;
                return(true);
            }

            return(false);
        }
Beispiel #10
0
        void UpdateColorSelectorAndSlider(bool inputValid, Ray inputRay, Collider parentCollider)
        {
            // Reset our input object if we're not holding the trigger.
            if (!InputManager.m_Instance.GetCommand(InputManager.SketchCommands.Activate))
            {
                ResetActiveInputObject();
            }

            // Color limits if we're tied to the brush color.
            float luminanceMin  = 0.0f;
            float saturationMax = 1.0f;
            BrushColorController brushController = m_ColorController as BrushColorController;

            if (brushController != null)
            {
                luminanceMin  = brushController.BrushLuminanceMin;
                saturationMax = brushController.BrushSaturationMax;
            }

            // Cache mode cause we use it a bunch.
            ColorPickerMode mode = ColorPickerUtils.GetActiveMode(m_ColorController.IsHdr);

            // Check for collision against our color slider first.
            RaycastHit hitInfo;

            if (m_ActiveInputObject == null || m_ActiveInputObject == m_ColorPickerSlider.gameObject)
            {
                bool validCollision = BasePanel.DoesRayHitCollider(inputRay,
                                                                   m_ColorPickerSlider.GetCollider(), out hitInfo);

                // TODO : ColorPickerSlider should be a UIComponent that handles this stuff
                // on its own.
                // If we're not colliding with the slider, but we were before, get our collision with
                // our parent collider.
                if (!validCollision && m_ActiveInputObject == m_ColorPickerSlider.gameObject)
                {
                    validCollision = BasePanel.DoesRayHitCollider(inputRay, parentCollider, out hitInfo);
                }

                if (validCollision)
                {
                    // Over slider, check for mouse down.
                    if (InputManager.m_Instance.GetCommand(InputManager.SketchCommands.Activate))
                    {
                        float value = ColorPickerUtils.ApplySliderConstraint(mode,
                                                                             m_ColorPickerSlider.GetValueFromHit(hitInfo),
                                                                             luminanceMin, saturationMax);
                        UpdateSelectorSlider(value);
                        UpdateSliderPosition();
                        Color newColor;
                        if (ColorPickerUtils.RawValueToColor(mode,
                                                             m_ColorPickerSelector.RawValue, out newColor))
                        {
                            m_ColorController.SetCurrentColorSilently(newColor);
                            TriggerColorPicked(newColor);
                        }
                        else
                        {
                            // Indicates some logic fault: the user isn't modifying the color plane,
                            // so why is the color plane's value outside the valid range?
                            Debug.LogErrorFormat("Unexpected bad RawValue. mode:{0} val:{1}", mode,
                                                 m_ColorPickerSelector.RawValue);
                        }

                        SketchSurfacePanel.m_Instance.VerifyValidToolWithColorUpdate();
                        m_ActiveInputObject = m_ColorPickerSlider.gameObject;
                    }
                }
            }

            if (m_ActiveInputObject == null || m_ActiveInputObject == m_ColorPickerSelector.gameObject)
            {
                if (BasePanel.DoesRayHitCollider(inputRay, m_ColorPickerSelector.GetCollider(),
                                                 out hitInfo))
                {
                    // Over color picker, check for input.
                    if (InputManager.m_Instance.GetCommand(InputManager.SketchCommands.Activate))
                    {
                        Vector3 value = ColorPickerUtils.ApplyPlanarConstraint(
                            m_ColorPickerSelector.GetValueFromHit(hitInfo),
                            mode, luminanceMin, saturationMax);
                        Color color;
                        if (ColorPickerUtils.RawValueToColor(mode, value, out color))
                        {
                            m_ColorPickerSelector.RawValue = value;
                            m_ColorController.SetCurrentColorSilently(color);
                            TriggerColorPicked(color);
                            m_ColorPickerSlider.OnColorChanged(mode, value);

                            SketchSurfacePanel.m_Instance.VerifyValidToolWithColorUpdate();
                            m_ActiveInputObject = m_ColorPickerSelector.gameObject;
                        }
                    }
                }
            }
        }
Beispiel #11
0
 override public bool RaycastAgainstCustomCollider(Ray ray,
                                                   out RaycastHit hitInfo, float dist)
 {
     return(BasePanel.DoesRayHitCollider(ray, GetCollider(), out hitInfo));
 }