using UnityEngine;
using System.Collections;
using UnityEngine.UI;
publicclass Example : MonoBehaviour {
public InputField mainInputField;
// Activate the main input field when the scene starts.void Start ()
{
mainInputField.ActivateInputField();
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
方法2 EventSystem.SetSelectedGameObject
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
publicclass Example : MonoBehaviour {
public InputField mainInputField;
// Activate the main input field when the scene starts.void Start ()
{
EventSystem.current.SetSelectedGameObject(mainInputField.gameObject);
}
}