다국어 설정 모달 UI 작업

This commit is contained in:
정영민
2025-05-07 17:13:21 +09:00
parent 5fcf8927f9
commit c719b706c1
7 changed files with 2784 additions and 29 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: bb4fd155efe15a040bf1c1c936399a6a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
{
"defaultLanguage": "Ko",
"languages": {
"Ko": "한국어",
"En": "English",
"Ja": "日本語"
}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: be71b5d18f50b9f4791093ac7cf722d7
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using XRLib.UI;
using TMPro;
using UnityEngine.UI;
using Newtonsoft.Json;
using TriLibCore.SFB;
using System.Text;
namespace XED
{
[Serializable]
public class LanguageConfig
{
public string defaultLanguage;
public Dictionary<string, string> languages;
}
public class Panel_MultilingualSettingModal : PanelBase
{
public TMP_Dropdown Dropdown_Languages;
public Button Button_OpenFile;
public Button Button_Save;
private string selectedLanguage;
private Dictionary<string, string> languages = new Dictionary<string, string>();
private string json;
public string saveLanguage;
public override void AfterAwake()
{
Button_OpenFile.onClick.AddListener(OnClickOpenFileButton);
Button_Save.onClick.AddListener(OnClickSaveButton);
}
void OnClickOpenFileButton()
{
StandaloneFileBrowser.OpenFilePanelAsync("Open File", "", "json", false, LoadJson);
}
void OnClickSaveButton()
{
saveLanguage = selectedLanguage;
}
void LoadJson(IList<ItemWithStream> items)
{
if (items != null && items.Count > 0)
{
var item = items[0];
using (var reader = new StreamReader(item.OpenStream(), Encoding.UTF8))
{
json = reader.ReadToEnd();
}
}
else
{
Debug.LogWarning("파일을 선택하지 않았습니다.");
}
var data = JsonConvert.DeserializeObject<LanguageConfig>(json);
if (data == null || data.languages == null)
{
Debug.LogError("데이터가 존재하지 않습니다.");
return;
}
languages = data.languages;
SetLanguageDropdown();
}
private void SetLanguageDropdown()
{
Dropdown_Languages.ClearOptions();
List<string> options = new List<string>();
foreach (var language in languages.Keys)
{
options.Add(language);
}
Dropdown_Languages.AddOptions(options);
Dropdown_Languages.onValueChanged.AddListener(OnLanguageDropdownValueChanged);
var languageKey = Dropdown_Languages.options[0].text;
selectedLanguage = languages[languageKey];
}
private void OnLanguageDropdownValueChanged(int index)
{
var languageKey = Dropdown_Languages.options[index].text;
selectedLanguage = languages[languageKey];
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 4af5f74e38688c3408f7bc2ef1ff30f8