fix: 캐릭터 생성 시 영문만 입력되도록 수정
This commit is contained in:
@@ -377,11 +377,11 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
m_UiScaleMode: 1
|
m_UiScaleMode: 1
|
||||||
m_ReferencePixelsPerUnit: 1
|
m_ReferencePixelsPerUnit: 100
|
||||||
m_ScaleFactor: 1
|
m_ScaleFactor: 1
|
||||||
m_ReferenceResolution: {x: 1920, y: 1080}
|
m_ReferenceResolution: {x: 1920, y: 1080}
|
||||||
m_ScreenMatchMode: 0
|
m_ScreenMatchMode: 0
|
||||||
m_MatchWidthOrHeight: 0
|
m_MatchWidthOrHeight: 0.5
|
||||||
m_PhysicalUnit: 3
|
m_PhysicalUnit: 3
|
||||||
m_FallbackScreenDPI: 96
|
m_FallbackScreenDPI: 96
|
||||||
m_DefaultSpriteDPI: 96
|
m_DefaultSpriteDPI: 96
|
||||||
@@ -421,6 +421,7 @@ MonoBehaviour:
|
|||||||
createButton: {fileID: 1887714318721360375}
|
createButton: {fileID: 1887714318721360375}
|
||||||
playerDatas: []
|
playerDatas: []
|
||||||
nicknameCondition: {fileID: 6220890634190874460}
|
nicknameCondition: {fileID: 6220890634190874460}
|
||||||
|
nicknameInputField: {fileID: 0}
|
||||||
characterCreateUI_Modal: {fileID: 7298901665149865196}
|
characterCreateUI_Modal: {fileID: 7298901665149865196}
|
||||||
blackCat_Spotlight: {fileID: 6897867871924581457}
|
blackCat_Spotlight: {fileID: 6897867871924581457}
|
||||||
whiteCat_Spotlight: {fileID: 6223168446447065192}
|
whiteCat_Spotlight: {fileID: 6223168446447065192}
|
||||||
@@ -1236,7 +1237,19 @@ MonoBehaviour:
|
|||||||
m_Calls: []
|
m_Calls: []
|
||||||
m_OnValueChanged:
|
m_OnValueChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
m_Calls: []
|
m_Calls:
|
||||||
|
- m_Target: {fileID: 6736657530173519912}
|
||||||
|
m_TargetAssemblyTypeName: TON.CharaterCreateUI, Assembly-CSharp
|
||||||
|
m_MethodName: RemoveNonEnglishCharacters
|
||||||
|
m_Mode: 1
|
||||||
|
m_Arguments:
|
||||||
|
m_ObjectArgument: {fileID: 0}
|
||||||
|
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||||
|
m_IntArgument: 0
|
||||||
|
m_FloatArgument: 0
|
||||||
|
m_StringArgument:
|
||||||
|
m_BoolArgument: 0
|
||||||
|
m_CallState: 2
|
||||||
m_OnTouchScreenKeyboardStatusChanged:
|
m_OnTouchScreenKeyboardStatusChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
m_Calls: []
|
m_Calls: []
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Assertions;
|
using UnityEngine.Assertions;
|
||||||
@@ -16,6 +17,7 @@ namespace TON
|
|||||||
[SerializeField] private TextMeshProUGUI nicknameCondition;
|
[SerializeField] private TextMeshProUGUI nicknameCondition;
|
||||||
|
|
||||||
|
|
||||||
|
public TMP_InputField nicknameInputField;
|
||||||
public GameObject characterCreateUI_Modal;
|
public GameObject characterCreateUI_Modal;
|
||||||
public GameObject blackCat_Spotlight;
|
public GameObject blackCat_Spotlight;
|
||||||
public GameObject whiteCat_Spotlight;
|
public GameObject whiteCat_Spotlight;
|
||||||
@@ -28,6 +30,14 @@ namespace TON
|
|||||||
|
|
||||||
// 처음에는 버튼을 비활성화
|
// 처음에는 버튼을 비활성화
|
||||||
createButton.interactable = false;
|
createButton.interactable = false;
|
||||||
|
|
||||||
|
|
||||||
|
// 입력 필드가 할당되지 않았다면 현재 게임 오브젝트의 InputField 컴포넌트를 가져옵니다.
|
||||||
|
if (nicknameInputField == null)
|
||||||
|
nicknameInputField = GetComponent<TMP_InputField>();
|
||||||
|
|
||||||
|
// 입력 필드의 문자 확인 이벤트에 메서드 연결
|
||||||
|
nicknameInputField.onValidateInput += ValidateInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectCharacter(string characterType)
|
public void SelectCharacter(string characterType)
|
||||||
@@ -63,6 +73,26 @@ namespace TON
|
|||||||
characterCreateUI_Modal.SetActive(true);
|
characterCreateUI_Modal.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private char ValidateInput(string text, int charIndex, char addedChar)
|
||||||
|
{
|
||||||
|
// 영문 대소문자만 허용 (A-Z, a-z)
|
||||||
|
if (Regex.IsMatch(addedChar.ToString(), @"^[a-zA-Z]+$"))
|
||||||
|
{
|
||||||
|
return addedChar;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 영문 이외의 문자는 무시
|
||||||
|
return '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 추가 옵션: 기존 텍스트에 영문 이외의 문자가 있다면 제거하는 메서드
|
||||||
|
public void RemoveNonEnglishCharacters()
|
||||||
|
{
|
||||||
|
string englishOnly = Regex.Replace(nicknameInputField.text, @"[^a-zA-Z]", "");
|
||||||
|
nicknameInputField.text = englishOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void OnClickConfirmButton()
|
public void OnClickConfirmButton()
|
||||||
{
|
{
|
||||||
TMP_InputField characterName = characterCreateUI_Modal.GetComponentInChildren<TMP_InputField>();
|
TMP_InputField characterName = characterCreateUI_Modal.GetComponentInChildren<TMP_InputField>();
|
||||||
|
|||||||
Reference in New Issue
Block a user