private void FindTouchReferences()
 {
     touch            = FindObjectOfType <LeanTouch>();
     fingerSwipeLeft  = GameObject.Find("SwipeLeft").GetComponent <LeanFingerSwipe>();
     fingerSwipeRight = GameObject.Find("SwipeRight").GetComponent <LeanFingerSwipe>();
     fingerTap        = GameObject.Find("LeanTouch").GetComponent <LeanFingerTap>();
 }
Пример #2
0
        private void Awake()
        {
            _lfsUp    = gameObject.AddComponent <LeanFingerSwipe>();
            _lfsLeft  = gameObject.AddComponent <LeanFingerSwipe>();
            _lfsDown  = gameObject.AddComponent <LeanFingerSwipe>();
            _lfsRight = gameObject.AddComponent <LeanFingerSwipe>();

            ConfigureLeanScripts();
        }
Пример #3
0
    // Start is called before the first frame update
    void Start()
    {
        lfs = FindObjectOfType <LeanFingerSwipe>();

        cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
        cube.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 2;
        Rigidbody rb = cube.AddComponent <Rigidbody>();

        rb.useGravity = false;
    }
Пример #4
0
        } //END CheckIfWeShouldAddMeshColliderToModel

        //---------------------------------------//
        private void CheckIfWeShouldAddRigidbodyToModel()
        //---------------------------------------//
        {

            //Check if we should add a Rigidbody to the model
            if( model != null && addMeshCollider && addRigidbody && _meshCollider != null )
            {
                //Only add a Rigidbody if there isn't one already
                if( model.GetComponentInChildren<Rigidbody>() == null )
                {
                    _rigidbody = _meshCollider.gameObject.AddComponent<Rigidbody>();
                }
                else
                {
                    _rigidbody = model.GetComponentInChildren<Rigidbody>();
                }

                //Disable gravity until the floor plane has been created, otherwise it will fall through the floor!
                _rigidbody.isKinematic = false;
                _rigidbody.useGravity = false;
                _rigidbody.mass = 1f;
                _rigidbody.drag = dragEndEaseSpeed;
                _rigidbody.angularDrag = dragEndEaseSpeed;
                _rigidbody.freezeRotation = true;

                //Setup the other features we'll need to apply physics
#if LEANTOUCH
                //Add a LeanTouchRigidbody component to the model
                if( leanForceRigidbody == null )
                {
                    leanForceRigidbody = _meshCollider.gameObject.AddComponent<LeanForceRigidbody>();
                    leanForceRigidbody.cachedBody = _rigidbody;
                }
                else
                {
                    Debug.Log( "model = " + model + ", leanForceRigidbody != null... " + leanForceRigidbody );
                }

                //Add a LeanFingerSwipe component to the model
                if( leanFingerSwipe == null )
                {
                    leanFingerSwipe = _meshCollider.gameObject.AddComponent<LeanFingerSwipe>();
                    leanFingerSwipe.Clamp = LeanFingerSwipe.ClampType.ScaledDelta;
                }

                //Connect the finger swipe event to the Rigidbody
                if( leanFingerSwipe != null && leanForceRigidbody != null )
                {
                    if( leanFingerSwipe.OnSwipeDelta == null ) { leanFingerSwipe.OnSwipeDelta = new LeanFingerSwipe.Vector2Event(); }
                    leanFingerSwipe.OnSwipeDelta.AddListener( leanForceRigidbody.Apply );
                }
#endif
            }

        } //END CheckIfWeShouldAddRigidbodyToModel
Пример #5
0
    private void Start()
    {
        currentGround = 0;
        coolDown      = 0;
        isDone        = false;

        uiManager.setActivePanel(false);

        leanFingerSwipe = GetComponent <LeanFingerSwipe>();
        Debug.Log(gameObject.name);
    }
Пример #6
0
        } //END CheckIfWeShouldChangeModelOnStart

        //--------------------------------//
        /// <summary>
        /// Replaces the existing instantiated 3D model with the one passed in. Expects a prefab/gameObject reference to clone
        /// </summary>
        /// <param name="newModelToClone">The GameObject prefab we want to clone</param>
        public void ChangeModel( GameObject newModelToClone )
        //--------------------------------//
        {
#if LEANTOUCH
            leanForceRigidbody = null;
            leanFingerSwipe = null;
#endif

            //Destroy any existing model(s)
            if( faceCameraTransform.childCount > 0 )
            {
#if UNITY_EDITOR
                //Wait a moment before calling DestroyImmediate to make sure no logic is running
                UnityEditor.EditorApplication.delayCall += () =>
                {
                    DestroyImmediate( faceCameraTransform.GetChild(0).gameObject );
                };
#else
                Destroy( faceCameraTransform.GetChild(0).gameObject );
#endif
            }

            //Instantiate the new model to show
            if( newModelToClone != null )
            {
                model = Instantiate( newModelToClone, faceCameraTransform );
                
                //Remove (Clone) from the models name
                if( model.name.Contains( "(Clone)" ))
                {
                    string[] words = model.name.Split( '(' );
                    model.name = words[ 0 ];
                }
                
                model.SetActive( true );

                transformToMove = this.transform;
                transformToPinch = this.transform;
                transformToTwist = this.transform;
                /*
                transformToMove = model.transform;
                transformToPinch = model.transform;
                transformToTwist = model.transform;
                */

            }

            //Add a ColorTweenManager to the new model, and link all of the renderers to it
            if ( model.GetComponent<UIColorTweenManager>() == null )
            {
                uiColorTweenManager = model.AddComponent<UIColorTweenManager>();
            }
            else
            {
                uiColorTweenManager = model.GetComponent<UIColorTweenManager>();
            }

            //Find all of the Renderers on the object, attach a UIColorTweener to those gameObjects and link them to the uiColorTweenManager
            if( model.GetComponentInChildren<Renderer>() != null )
            {
                uiColorTweenManager.tweeners = new List<UIColorTweener>();

                foreach( Renderer rend in model.GetComponentsInChildren<Renderer>().ToList() )
                {
                    if ( rend != null && rend.gameObject.GetComponent<UIColorTweener>() == null )
                    {
                        uiColorTweenManager.tweeners.Add( rend.gameObject.AddComponent<UIColorTweener>() );
                    }
                    else if( rend != null && rend.gameObject.GetComponent<UIColorTweener>() != null )
                    {
                        uiColorTweenManager.tweeners.Add( rend.gameObject.GetComponent<UIColorTweener>() );
                    }
                }
            }

            CheckIfWeShouldAddMeshColliderToModel();

            CheckIfWeShouldAddRigidbodyToModel();

        } //END ChangeModel
Пример #7
0
 private void Start()
 {
     random = new System.Random();
     swipe  = GetComponent <LeanFingerSwipe>();
     swipe.OnFinger.AddListener(ThrowABall);
 }
Пример #8
0
 void Start()
 {
     lfs = FindObjectOfType <LeanFingerSwipe>();
     lfs.OnSwipeDelta.AddListener(ShootObject);
 }