Search code examples
c#unity-game-engine

Creating navigation between Unity3D instantiated UI elements


So in Unity3D I have a script that reads a JSON delivered by a database and converts every field into an UnityEngine.UI InputField so the user can edit the entry. The code literally instantiates an InputField prefab.

The problem is there is no navigation between them, if I just press TAB or any arrow key the focus won't change, and that is not only very user-unfriendly but also annoying.

So my question here is if there is a way by code to change the navigation in the moment I instantiate them, or if should I just go straight making myself a script for that.

Thanks in advance!


Solution

  • Sure, you can set those programmatically

    http://docs.unity3d.com/ScriptReference/UI.Navigation.html

    enter image description here

    Suggest you first just set up some buttons in the Editor, and experiment with it in the editor. THen, get in to doing it in code.

    It's the most powerful / unknown feature in Unity!