コード例 #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="gameObject"></param>
 /// <param name="selectable"></param>
 private void HandleIncludeChildren(GameObject gameObject, LeanSelectable selectable)
 {
     foreach (Transform child in gameObject.transform)
     {
         LeanSelectable s = AddSelectableComponent(child.gameObject);
         s.DeselectOnUp = true;
         s.OnSelect.AddListener((LeanFinger finger) =>
         {
             selectable.Select(finger);
         });
         s.OnDeselect.AddListener(() =>
         {
             selectable.Deselect();
         });
     }
 }
コード例 #2
0
        } //END Update

        //------------------------------------//
        private void CheckIfLeanSelectableShouldBeEnabled()
        //------------------------------------//
        {

#if LEANTOUCH
            if( RequireCollider() && leanSelectable != null )
            {
                //If our Two-Touch Input is starting over a LeanSelectable, then enable the LeanSelectable until the gesture ends
                if( LeanTouch.Fingers != null && LeanTouch.Fingers.Count == 2 )
                {
                    bool fingersTouchingSelectable = true;

                    foreach( LeanFinger finger in LeanTouch.Fingers )
                    {
                        bool foundColliderOnFinger = false;

                        //If the finger is in any phase besides starting the input, prevent activation of the LeanSelectable
                        if( !IsInputInStartPhase() )
                        {
                            fingersTouchingSelectable = false;
                            break;
                        }

                        //Are we looking for a 3D collider?
                        if( LookForBlockModel() ||
                            LookForBlockButton() ||
                            LookForCollider() ||
                            LookForTag3D() )
                        {
                            //If we cannot locate the 3D collider we're looking for, 
                            //then prevent activation of the LeanSelectable (which will prevent the gesture)
                            if( !CheckFor3DCollider( Camera.main, finger.ScreenPosition ) )
                            {
                                fingersTouchingSelectable = false;
                                break;
                            }
                            else
                            {
                                foundColliderOnFinger = true;
                            }
                        }

                        //Otherwise, check for a 2D collider
                        if( !foundColliderOnFinger &&
                            ( LookForBlockButton() ||
                              LookForCollider2D() ||
                              LookForTag2D() ) )
                        {
                            if( !CheckFor2DCollider( Camera.main, finger.ScreenPosition ) )
                            {
                                fingersTouchingSelectable = false;
                                break;
                            }
                        }
                        else
                        {
                            foundColliderOnFinger = true;
                        }
                    }

                    //After finishing our check, if all of the fingers are touching the LeanSelectable, then enable it
                    if( fingersTouchingSelectable )
                    {
                        leanSelectable.Select();
                    }

                }

            }
#endif

        } //END CheckIfLeanSelectableShouldBeEnabled