Tanoda
ReturnKeyTriggersButton.cs
Go to the documentation of this file.
1
4
6namespace UnityEngine.UI
7{
8 [RequireComponent(typeof(InputField))]
9 [AddComponentMenu("UI/Extensions/Return Key Trigger")]
10 public class ReturnKeyTriggersButton : MonoBehaviour, ISubmitHandler
11 {
12 private EventSystem _system;
13
14 public Button button;
15 private bool highlight = true;
16 public float highlightDuration = 0.2f;
17
18 void Start()
19 {
20 _system = EventSystem.current;
21 }
22
23 void RemoveHighlight()
24 {
25 button.OnPointerExit(new PointerEventData(_system));
26 }
27
28 public void OnSubmit(BaseEventData eventData)
29 {
30 if (highlight) button.OnPointerEnter(new PointerEventData(_system));
31 button.OnPointerClick(new PointerEventData(_system));
32
33 if (highlight) Invoke("RemoveHighlight", highlightDuration);
34 }
35 }
36}
UnityEngine.UI.Button Button
Definition: Pointer.cs:7