Exemplo n.º 1
0
        } //END Awake

        //-------------------------------//
        public override void PrepareEvent()
        //-------------------------------//
        {
            
            if( action == Actions.CopyValues )
            {
                if( TransformAction_CopyValues() && copyToTransform != null )
                {
                    eventReady = true;
                }
                else if( TransformAction_CopyValues() && copyToRectTransform != null )
                {
                    eventReady = true;
                }
            }
            else if( action == Actions.SetValues )
            {
                if( TransformType_Transform() && ChangeTransform != null )
                {
                    eventReady = true;
                }
                else if( TransformType_RectTransform() && ChangeRectTransform != null )
                {
                    eventReady = true;
                }
            }
            else if( action == Actions.EnablePinchToScale )
            {
#if LEANTOUCH
                leanSelectable = null;
                leanManualRotateSmooth = null;
                leanMultiTwist = null;
                leanScale = null;
                
                if( IsGestureTransformTypeBlockModel() && blockModelToChange != null )
                {
                    eventReady = true;
                }
                else if( IsGestureTransformTypeTransform() && transformToChange != null )
                {
                    eventReady = true;
                }
                else
                {
                    eventReady = false;
                }
#else
                eventReady = false;
#endif
            }
            else if( action == Actions.EnableTwistToRotate )
            {
#if LEANTOUCH
                leanSelectable = null;
                leanManualRotateSmooth = null;
                leanMultiTwist = null;
                leanScale = null;

                if( IsGestureTransformTypeBlockModel() && blockModelToChange != null )
                {
                    eventReady = true;
                }
                else if( IsGestureTransformTypeTransform() && transformToChange != null )
                {
                    eventReady = true;
                }
                else
                {
                    eventReady = false;
                }
#else
                eventReady = false;
#endif
            }
            else if( action == Actions.DisablePinchToScale )
            {
#if LEANTOUCH
                if( IsGestureTransformTypeBlockModel() && blockModelToChange != null )
                {
                    eventReady = true;
                }
                else if( IsGestureTransformTypeTransform() && transformToChange != null )
                {
                    eventReady = true;
                }
                else
                {
                    eventReady = false;
                }
#else
                eventReady = false;
#endif
            }
            else if( action == Actions.DisableTwistToRotate )
            {
#if LEANTOUCH
                if( IsGestureTransformTypeBlockModel() && blockModelToChange != null )
                {
                    eventReady = true;
                }
                else if( IsGestureTransformTypeTransform() && transformToChange != null )
                {
                    eventReady = true;
                }
                else
                {
                    eventReady = false;
                }
#else
                eventReady = false;
#endif
            }
            else if( action == Actions.ReEnablePinchToScale )
            {
#if LEANTOUCH
                if( IsGestureTransformTypeBlockModel() && blockModelToChange != null )
                {
                    eventReady = true;
                }
                else if( IsGestureTransformTypeTransform() && transformToChange != null )
                {
                    eventReady = true;
                }
                else
                {
                    eventReady = false;
                }
#else
                eventReady = false;
#endif
            }
            else if( action == Actions.ReEnableTwistToRotate )
            {
#if LEANTOUCH
                if( IsGestureTransformTypeBlockModel() && blockModelToChange != null )
                {
                    eventReady = true;
                }
                else if( IsGestureTransformTypeTransform() && transformToChange != null )
                {
                    eventReady = true;
                }
                else
                {
                    eventReady = false;
                }
#else
                eventReady = false;
#endif
            }

        } //END PrepareEvent
Exemplo n.º 2
0
        } //END CallDisablePinchToScaleEvent

        //------------------------------------//
        private void CallEnableTwistToRotateEvent()
        //------------------------------------//
        {

#if LEANTOUCH
            Transform transformToTwist = null;

            if( IsGestureTransformTypeBlockModel() && blockModelToChange != null )
            {
                transformToTwist = blockModelToChange.GetTwistTransform();
            }
            else if( IsGestureTransformTypeTransform() && transformToChange != null )
            {
                transformToTwist = transformToChange;
            }

            //Debug.Log( "CallEnableTwistToRotateEvent() transformToTwist = " + transformToTwist.name );

            if( transformToTwist != null )
            {

                AddOrEnableLeanSelectableOnGestureTarget( transformToTwist );

                //Add the LeanMultiTwist component to the object we want to rotate
                if( leanMultiTwist != null && !leanMultiTwist.enabled )
                {
                    leanMultiTwist.enabled = true;
                }

                if( leanMultiTwist == null && transformToTwist.GetComponent<LeanMultiTwist>() == null )
                {
                    leanMultiTwist = transformToTwist.gameObject.AddComponent<LeanMultiTwist>();
                }

                if( leanMultiTwist == null && transformToTwist.GetComponent<LeanMultiTwist>() != null )
                {
                    leanMultiTwist = transformToTwist.gameObject.GetComponent<LeanMultiTwist>();
                }

                //Also add the leanManualRotateSmooth component to the object we want to rotate
                if( leanManualRotateSmooth != null && !leanManualRotateSmooth.enabled )
                {
                    leanManualRotateSmooth.enabled = true;
                }

                if( leanManualRotateSmooth == null && transformToTwist.GetComponent<LeanManualRotateSmooth>() == null )
                {
                    leanManualRotateSmooth = transformToTwist.gameObject.AddComponent<LeanManualRotateSmooth>();
                }

                if( leanManualRotateSmooth == null && transformToTwist.GetComponent<LeanManualRotateSmooth>() )
                {
                    leanManualRotateSmooth = transformToTwist.GetComponent<LeanManualRotateSmooth>();
                }

                if( leanSelectable != null && leanSelectable.enabled && 
                    leanMultiTwist != null && leanMultiTwist.enabled &&
                    leanManualRotateSmooth != null && leanManualRotateSmooth.enabled )
                {

                    if( requireStartOnCollider )
                    {
                        leanMultiTwist.RequiredSelectable = leanSelectable;
                    }
                    else
                    {
                        leanMultiTwist.RequiredSelectable = null;
                    }

                    Vector3 rotationAxis = Vector3.zero;

                    if( rotateX ) { rotationAxis = new Vector3( -1f, rotationAxis.y, rotationAxis.z ); }
                    if( rotateY ) { rotationAxis = new Vector3( rotationAxis.x, -1f, rotationAxis.z ); }
                    if( rotateZ ) { rotationAxis = new Vector3( rotationAxis.x, rotationAxis.y, -1f ); }

                    leanManualRotateSmooth.Axis = rotationAxis;

                    leanManualRotateSmooth.Multiplier = rotationMultiplier;

                    leanManualRotateSmooth.Dampening = rotationDampening;

                    //If our twist event listener is null, create one
                    if( leanMultiTwist.OnTwist == null )
                    {
                        leanMultiTwist.OnTwist = new LeanMultiTwist.FloatEvent();
                    }

                    //Add the Rotate command to the twist listener
                    if( leanMultiTwist.OnTwist != null &&
                        ( leanMultiTwist.OnTwist.GetPersistentEventCount() == 0 ||
                          leanMultiTwist.OnTwist.GetPersistentTarget( 0 ) != leanManualRotateSmooth ) )
                    {
                        //Add a Non-Persistent listener to this event. This will work but it won't be visible in the editor and won't be linked to the event after play mode ends
                        leanMultiTwist.OnTwist.AddListener( leanManualRotateSmooth.Rotate );
                    }
                    
                    if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
                }
            }
#endif

        } //END CallEnableTwistToRotateEvent