public static bool SpecialNavigationSystem( this UFEScreen screen, IDictionary <InputReferences, InputEvents> player1PreviousInputs, IDictionary <InputReferences, InputEvents> player1CurrentInputs, IDictionary <InputReferences, InputEvents> player2PreviousInputs, IDictionary <InputReferences, InputEvents> player2CurrentInputs, MoveCursorCallback moveCursorCallback = null, ActionCallback confirmCallback = null, ActionCallback cancelCallback = null ) { return (screen.SpecialNavigationSystem( player1PreviousInputs, player1CurrentInputs, moveCursorCallback, confirmCallback, cancelCallback ) || screen.SpecialNavigationSystem( player2PreviousInputs, player2PreviousInputs, moveCursorCallback, confirmCallback, cancelCallback )); }
public static bool SpecialNavigationSystem( this UFEScreen screen, MoveCursorCallback moveCursorCallback = null, ActionCallback confirmCallback = null, ActionCallback cancelCallback = null ) { return (screen.SpecialNavigationSystem(1, moveCursorCallback, confirmCallback, cancelCallback) || screen.SpecialNavigationSystem(2, moveCursorCallback, confirmCallback, cancelCallback)); }
public static bool DefaultNavigationSystem( this UFEScreen screen, IDictionary <InputReferences, InputEvents> previousInputs, IDictionary <InputReferences, InputEvents> currentInputs, AudioClip moveCursorSound = null, AudioClip confirmSound = null, AudioClip cancelSound = null, Action cancelAction = null ) { if (UFE.eventSystem != null && UFE.eventSystem.isActiveAndEnabled) { //--------------------------------------------------------------------------------------------------------- // First, check if the current Selectable Object is an Input Field, because it's a special case... //--------------------------------------------------------------------------------------------------------- GameObject currentGameObject = UFE.eventSystem.currentSelectedGameObject; InputField inputField = currentGameObject != null?currentGameObject.GetComponent <InputField>() : null; if (inputField != null) { //----------------------------------------------------------------------------------------------------- // If it's an Input Field, check if the user wants to write a text // or if he wants to move the caret or exit from the Input Field... //----------------------------------------------------------------------------------------------------- Vector3 direction = (Input.GetKeyDown(KeyCode.UpArrow) ? Vector3.up : Vector3.zero) + (Input.GetKeyDown(KeyCode.DownArrow) ? Vector3.down : Vector3.zero); if ( direction != Vector3.zero || Input.GetKeyDown(KeyCode.Tab) || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter) ) { Selectable previousSelectable = inputField; Selectable nextSelectable = null; if (direction != Vector3.zero) { nextSelectable = currentGameObject.FindSelectable(direction, false); } if (nextSelectable == null || previousSelectable == nextSelectable) { nextSelectable = currentGameObject.FindSelectable(Vector3.right, false); if (nextSelectable == null || previousSelectable == nextSelectable) { nextSelectable = currentGameObject.FindSelectable(Vector3.down, false); if (nextSelectable == null || previousSelectable == nextSelectable) { nextSelectable = currentGameObject.FindSelectable(Vector3.left, false); if (nextSelectable == null || previousSelectable == nextSelectable) { nextSelectable = currentGameObject.FindSelectable(Vector3.up, false); } } } } screen.HighlightOption(nextSelectable); } else { inputField.OnUpdateSelected(new AxisEventData(UFE.eventSystem)); } return(true); } else { //----------------------------------------------------------------------------------------------------- // Otherwise, invoke the "Special Navigation System" with the default functions //----------------------------------------------------------------------------------------------------- return(screen.SpecialNavigationSystem( previousInputs, currentInputs, new MoveCursorCallback(screen.DefaultMoveCursorAction, moveCursorSound), new ActionCallback(UFE.eventSystem.currentSelectedGameObject.DefaultConfirmAction, confirmSound), new ActionCallback(cancelAction.DefaultCancelAction, cancelSound) )); } } return(false); }