Merged in larsme/unity-ui-extensions/inputField_Enter_Submit_defocus_Input_Option (pull request #46)
Defocus Option and Demo for Input Enter Submit Scriptpull/413/head
commit
d7d293a348
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9faa2b8f6b738d543a53cea7512c605d
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 45161b084cced954b88fb3d619bc7f9a
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -13,9 +13,13 @@ namespace UnityEngine.UI.Extensions
|
||||||
public class InputFieldEnterSubmit : MonoBehaviour
|
public class InputFieldEnterSubmit : MonoBehaviour
|
||||||
{
|
{
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class EnterSubmitEvent : UnityEvent<string> { }
|
public class EnterSubmitEvent : UnityEvent<string>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public EnterSubmitEvent EnterSubmit;
|
public EnterSubmitEvent EnterSubmit;
|
||||||
|
public bool defocusInput = true;
|
||||||
private InputField _input;
|
private InputField _input;
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
|
@ -26,8 +30,13 @@ namespace UnityEngine.UI.Extensions
|
||||||
|
|
||||||
public void OnEndEdit(string txt)
|
public void OnEndEdit(string txt)
|
||||||
{
|
{
|
||||||
if (!Input.GetKeyDown(KeyCode.Return) && !Input.GetKeyDown(KeyCode.KeypadEnter)) return;
|
if (!Input.GetKeyDown(KeyCode.Return) && !Input.GetKeyDown(KeyCode.KeypadEnter))
|
||||||
|
return;
|
||||||
EnterSubmit.Invoke(txt);
|
EnterSubmit.Invoke(txt);
|
||||||
|
if (defocusInput)
|
||||||
|
{
|
||||||
|
UnityEngine.EventSystems.EventSystem.current.SetSelectedGameObject(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue