Advertisement
Guest User

Табуляция

a guest
May 26th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4. using UnityEngine.EventSystems;
  5.  
  6. public class InputNavigator : MonoBehaviour
  7. {
  8.     EventSystem system;
  9.  
  10.     void Start()
  11.     {
  12.         system = EventSystem.current;// EventSystemManager.currentSystem;
  13.      
  14.     }
  15.     // Update is called once per frame
  16.     void Update()
  17.     {
  18.         if (Input.GetKeyDown(KeyCode.Tab))
  19.         {
  20.             Selectable next = system.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnDown();
  21.          
  22.             if (next != null)
  23.             {
  24.              
  25.                 InputField inputfield = next.GetComponent<InputField>();
  26.                 if (inputfield != null)
  27.                     inputfield.OnPointerClick(new PointerEventData(system));  //if it's an input field, also set the text caret
  28.              
  29.                 system.SetSelectedGameObject(next.gameObject, new BaseEventData(system));
  30.             }
  31.             //else Debug.Log("next nagivation element not found");
  32.          
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement