diff --git a/Unity-Files/Assets/Examples/Defender/Defender.unity b/Unity-Files/Assets/Examples/Defender/Defender.unity index 18a5c7d..420208a 100644 --- a/Unity-Files/Assets/Examples/Defender/Defender.unity +++ b/Unity-Files/Assets/Examples/Defender/Defender.unity @@ -5053,7 +5053,7 @@ MonoBehaviour: m_Calls: - m_Target: {fileID: 839555747} m_TargetAssemblyTypeName: UsernameValidateSubmit, Assembly-CSharp - m_MethodName: ValidateInput + m_MethodName: buttonValidateInput m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} diff --git a/Unity-Files/Assets/Scripts/Menu/UsernameValidateSubmit.cs b/Unity-Files/Assets/Scripts/Menu/UsernameValidateSubmit.cs index 33ea6ba..f48f202 100644 --- a/Unity-Files/Assets/Scripts/Menu/UsernameValidateSubmit.cs +++ b/Unity-Files/Assets/Scripts/Menu/UsernameValidateSubmit.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; +using System.Threading.Tasks; public class UsernameValidateSubmit : MonoBehaviour { private void Start() @@ -15,5 +16,54 @@ public class UsernameValidateSubmit : MonoBehaviour { GameObject.Find("GameOverPanel").GetComponent<LeaderboardHandle>().SubmitScores(); } + else if (Input.GetKeyDown(KeyCode.Return)) + { + FlashRed(); + } + } + + public void buttonValidateInput() + { + if (GetComponent<InputField>().text.Length == 3) + { + GameObject.Find("GameOverPanel").GetComponent<LeaderboardHandle>().SubmitScores(); + } + else + { + FlashRed(); + } + } + + public async void FlashRed() + { + try + { + if (GetComponent<InputField>().text != "") + { + Color defaultColor = GetComponent<InputField>().textComponent.color; + GetComponent<InputField>().textComponent.color = Color.red; + await Task.Delay(100); + GetComponent<InputField>().textComponent.color = defaultColor; + await Task.Delay(100); + GetComponent<InputField>().textComponent.color = Color.red; + await Task.Delay(100); + GetComponent<InputField>().textComponent.color = defaultColor; + } + else + { + Color defaultColor = GetComponent<InputField>().placeholder.color; + GetComponent<InputField>().placeholder.color = Color.red; + await Task.Delay(100); + GetComponent<InputField>().placeholder.color = defaultColor; + await Task.Delay(100); + GetComponent<InputField>().placeholder.color = Color.red; + await Task.Delay(100); + GetComponent<InputField>().placeholder.color = defaultColor; + } + } + catch (MissingReferenceException) + { + Debug.Log("Missing Reference: Ignoring Due to Async Winddown"); + } } }