Select your preferred scripting language. All code snippets will be displayed in this language.
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
CloseDoes the InputField currently have focus and is able to process events.
#pragma strict // Required when Using UI elements. public class Example { public var mainInputField; function Update() { //If the input field is focused, change its color to green. if (mainInputField.GetComponent.<InputField>().isFocused == true) { mainInputField.GetComponent.<Image>().color = Color.green; } } }
using UnityEngine; using System.Collections; using UnityEngine.UI; // Required when Using UI elements.
public class Example : MonoBehaviour { public GameObject mainInputField;
void Update() { //If the input field is focused, change its color to green. if (mainInputField.GetComponent<InputField>().isFocused == true) { mainInputField.GetComponent<Image>().color = Color.green; } } }