[한수빈] 홈 화면 UI 변경
26.01.29 - 프로젝트 잠긴 버전 추가 - 언어 설정 (한글만 가능하도록)
This commit is contained in:
51
Assets/Scripts/UI/LanguageController.cs
Normal file
51
Assets/Scripts/UI/LanguageController.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.Collections;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace OCTOPUS_TWIN
|
||||
{
|
||||
public class LanguageDropdownController : MonoBehaviour
|
||||
{
|
||||
[Header("UI References")]
|
||||
[SerializeField] private TMP_Dropdown languageDropdown; // 드롭다운 연결
|
||||
[SerializeField] private ToastPopup unsupportedPopup;
|
||||
|
||||
private int previousIndex = 0; // 이전에 선택했던 정상적인 인덱스 (기본값 0: KOR)
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 리스너 등록
|
||||
languageDropdown.onValueChanged.AddListener(OnLanguageChanged);
|
||||
|
||||
// 초기값 설정 (저장된 값이 없다면 0번 KOR로 가정)
|
||||
previousIndex = languageDropdown.value;
|
||||
}
|
||||
|
||||
private void OnLanguageChanged(int index)
|
||||
{
|
||||
// 선택된 옵션의 텍스트 가져오기
|
||||
string selectedOption = languageDropdown.options[index].text;
|
||||
|
||||
if (selectedOption == "ENG")
|
||||
{
|
||||
// 팝업 띄우기 (ToastPopup의 OnEnable -> PopupBase의 로직 실행됨)
|
||||
if (unsupportedPopup != null)
|
||||
{
|
||||
unsupportedPopup.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
// 값 되돌리기 (이벤트 없이)
|
||||
languageDropdown.SetValueWithoutNotify(previousIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 정상적인 언어(KOR)를 선택했다면
|
||||
// 현재 인덱스를 '이전 인덱스'로 저장해둠 (나중에 돌아올 곳)
|
||||
previousIndex = index;
|
||||
|
||||
// 여기에 실제 언어 변경 로직 추가 가능
|
||||
Debug.Log($"언어가 {selectedOption}로 변경되었습니다.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user