From 1d0f8360d31fc27f398ead482840fa93d8eb08a0 Mon Sep 17 00:00:00 2001 From: Hayyan Date: Tue, 27 Aug 2024 12:57:57 +0000 Subject: [PATCH] Upload files to "/" --- Api.meta | 8 +++++ Game.meta | 8 +++++ In Game UI.meta | 8 +++++ KeyboardInputManager.cs | 67 ++++++++++++++++++++++++++++++++++++ KeyboardInputManager.cs.meta | 11 ++++++ 5 files changed, 102 insertions(+) create mode 100644 Api.meta create mode 100644 Game.meta create mode 100644 In Game UI.meta create mode 100644 KeyboardInputManager.cs create mode 100644 KeyboardInputManager.cs.meta diff --git a/Api.meta b/Api.meta new file mode 100644 index 0000000..5f386cc --- /dev/null +++ b/Api.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 812fa61a641329a4e8837aeebadb1e21 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Game.meta b/Game.meta new file mode 100644 index 0000000..05ac197 --- /dev/null +++ b/Game.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: daf65223fa520944c8af872f13e1142c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/In Game UI.meta b/In Game UI.meta new file mode 100644 index 0000000..b901a90 --- /dev/null +++ b/In Game UI.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a6dae22a96146de4eb5b489c331eb7e2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/KeyboardInputManager.cs b/KeyboardInputManager.cs new file mode 100644 index 0000000..65cbc93 --- /dev/null +++ b/KeyboardInputManager.cs @@ -0,0 +1,67 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; +using TMPro; + +public class KeyboardInputManager : MonoBehaviour +{ + + private TMP_InputField inputField; + private string editText; + private string oldEditText; + private bool keepOldTextInField; + + void Start() + { + inputField = gameObject.GetComponent(); + inputField.onEndEdit.AddListener(EndEdit); + inputField.onValueChanged.AddListener(Editing); + inputField.onTouchScreenKeyboardStatusChanged.AddListener(ReportChangeStatus); + } + + private void ReportChangeStatus(TouchScreenKeyboard.Status newStatus) + { + if (newStatus == TouchScreenKeyboard.Status.Canceled) + { + keepOldTextInField = true; + } + + } + + private void Editing(string currentText) + { + oldEditText = editText; + editText = currentText; + + } + + private void EndEdit(string currentText) + { + if (keepOldTextInField) + { + //IMPORTANT ORDER + editText = oldEditText; + inputField.text = oldEditText; + + keepOldTextInField = false; + } + } + + public void ValidateInput() + { + string inputText = inputField.text; + + if (inputText.Length < 10) + { + inputField.GetComponent().color = Color.black; + } + else + { + inputField.GetComponent().color = Color.red; + } + } + + + +} \ No newline at end of file diff --git a/KeyboardInputManager.cs.meta b/KeyboardInputManager.cs.meta new file mode 100644 index 0000000..de3aa47 --- /dev/null +++ b/KeyboardInputManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ee4f2ab84d76f2340b28e0fde4af54c4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: