Exemplo n.º 1
0
 public void OnMyMouseDrag(LE_ObjectEditHandleCollider p_handleCollider, Vector3 p_axis)
 {
     m_activeHandle   = p_handleCollider;
     m_activeEditAxis = p_axis;
     m_lastDragFrame  = Time.frameCount;
 }
Exemplo n.º 2
0
        private void LateUpdate()
        {
            // destroy handle when target is destroyed or set to null
            if (m_target == null)
            {
                Destroy(gameObject);
                return;
            }

            // move handle to targets position
            transform.position = m_target.position;

            // apply transformation space
            if (!m_isTransforming)
            {
                if (m_editMode == LE_EObjectEditMode.SCALE || m_editSpace == LE_EObjectEditSpace.SELF)
                {
                    if (transform.rotation != m_target.rotation)
                    {
                        transform.rotation = m_target.rotation;                         // local move, rotate or scale
                    }
                }
                else if (transform.rotation != Quaternion.identity)
                {
                    transform.rotation = Quaternion.identity;                     // global move or rotate (global scale does not exist)
                }
            }

            if (m_lastDragFrame < Time.frameCount)
            {
                m_activeHandle    = null;
                m_activeEditAxis  = Vector3.zero;
                m_dragSkipCounter = 0;
                if (m_isTransforming)
                {
                    m_isTransforming = false;
                    if (OnEndTransform != null)
                    {
                        OnEndTransform(m_editMode, m_target);
                    }
                }
            }

            if (m_activeEditAxis.sqrMagnitude > 0.01)
            {
                if (!m_isTransforming)
                {
                    m_isTransforming = true;
                    if (OnBeginTransform != null)
                    {
                        OnBeginTransform(m_editMode, m_target);
                    }
                }

                switch (m_editMode)
                {
                case LE_EObjectEditMode.MOVE: Move(); break;

                case LE_EObjectEditMode.ROTATE: Rotate(); break;

                case LE_EObjectEditMode.SCALE: Scale(); break;

                case LE_EObjectEditMode.SMART: Smart(); break;
                }
                if (m_editMode != LE_EObjectEditMode.NO_EDIT && OnTransform != null)
                {
                    OnTransform(m_editMode, m_target);
                }
            }
            m_lastCursorPos = GetCursorPosition();
        }