Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        // Check selected point if mouse doesn't hit UI or the gizmo
        if (Input.GetMouseButtonDown(0) && RTGizmosEngine.Get.HoveredGizmo == null &&
            EventSystem.current.currentSelectedGameObject == null)
        {
            GameObject pickedObject = PickCurvePoint();
            if (pickedObject != m_selectedPoint)
            {
                ChangeSelectedPoint(pickedObject);
            }
        }

        if (Input.GetKeyDown(KeyCode.W))
        {
            EnableTranslationGizmo();
        }

        // Only key point can be rotated
        if (m_enableRotationGizmo && Input.GetKeyDown(KeyCode.E) &&
            m_curveController.IsRotationKey(m_selectedPoint))
        {
            EnableRotationGizmo();
        }

        // Update transform of gizmo because the transform of the selectPoint may be changed by UI
        if (m_selectedPoint)
        {
            m_objectTranslationGizmo.SetTargetObject(m_selectedPoint);
            m_objectRotationGizmo.SetTargetObject(m_selectedPoint);
        }
    }
Beispiel #2
0
    public void ChangeSelectedJoint(GameObject newSeletcedObject)
    {
        // Recover the color of the previous seleced joint
        if (m_selectedJoint != null)
        {
            m_selectedJoint.GetComponent <VirtualJointController>().ExitJoint();
        }

        // Store the new target object
        m_selectedJoint = newSeletcedObject;

        m_objectRotationGizmo.Gizmo.SetEnabled(false);
        m_objectTranslationGizmo.Gizmo.SetEnabled(false);

        // Check if the new target object is valid
        if (m_selectedJoint != null)
        {
            if (m_mode == Mode.FK)
            {
                m_objectRotationGizmo.SetTargetObject(m_selectedJoint);
                m_objectRotationGizmo.Gizmo.SetEnabled(true);
                m_objectTranslationGizmo.SetTargetObject(m_selectedJoint);
                m_objectTranslationGizmo.Gizmo.SetEnabled(true);
            }
            else if (m_mode == Mode.IK && m_selectedJoint.CompareTag("TargetJoint"))
            {
                m_objectTranslationGizmo.SetTargetObject(m_selectedJoint);
                m_objectTranslationGizmo.Gizmo.SetEnabled(true);
            }

            // Change the color of the new selected joint
            m_selectedJoint.GetComponent <VirtualJointController>().SelectJoint();
        }
    }
Beispiel #3
0
    private void OnTargetObjectChanged(GameObject newTargetObject)
    {
        // Store the new target object
        _targetObject = newTargetObject;

        // Is the target object valid?
        if (_targetObject != null)
        {
            _objectMoveGizmo.SetTargetObject(_targetObject);
            _objectRotationGizmo.SetTargetObject(_targetObject);
            _workGizmo.Gizmo.SetEnabled(true);
        }
        else
        {
            _objectMoveGizmo.Gizmo.SetEnabled(false);
            _objectRotationGizmo.Gizmo.SetEnabled(false);
        }
    }