2025-05-20 18:40:07 +09:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
using XRLib.UI;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using TMPro;
|
|
|
|
|
|
using TriLibCore.SFB;
|
2025-05-22 17:17:54 +09:00
|
|
|
|
using Studio.Util;
|
2025-05-20 18:40:07 +09:00
|
|
|
|
|
2025-05-23 19:00:09 +09:00
|
|
|
|
namespace Studio.UI
|
2025-05-20 18:40:07 +09:00
|
|
|
|
{
|
|
|
|
|
|
public enum AnimationStyle
|
|
|
|
|
|
{
|
|
|
|
|
|
Static, FadeIn, FadeOut
|
|
|
|
|
|
}
|
|
|
|
|
|
public enum ProgressBarStyle
|
|
|
|
|
|
{
|
|
|
|
|
|
None, Bar, Spinner, Skeleton
|
|
|
|
|
|
}
|
|
|
|
|
|
public enum DefultLanauge
|
|
|
|
|
|
{
|
|
|
|
|
|
Korean, English, Chinese, Japanese
|
|
|
|
|
|
}
|
|
|
|
|
|
public class Panel_AppSetting : PanelBase
|
|
|
|
|
|
{
|
|
|
|
|
|
private Button Button_ImageSelected;
|
|
|
|
|
|
private Image Image_Selected;
|
|
|
|
|
|
private TMP_Dropdown Dropdown_AnimationStyle;
|
|
|
|
|
|
|
|
|
|
|
|
private TMP_Dropdown Dropdown_ProgressBarStyle;
|
|
|
|
|
|
private Toggle Toggle_AutoStart;
|
|
|
|
|
|
|
|
|
|
|
|
private TMP_Dropdown Dropdown_DefaultLangauge;
|
|
|
|
|
|
private TMP_InputField InputField_LanguagePack;
|
|
|
|
|
|
private Button Button_LanguagePack;
|
|
|
|
|
|
|
2025-05-23 09:34:37 +09:00
|
|
|
|
private float ratio;
|
2025-05-25 15:27:25 +09:00
|
|
|
|
public Action onClose;
|
2025-05-29 00:41:06 +09:00
|
|
|
|
public Button Button_Close;
|
2025-05-23 09:34:37 +09:00
|
|
|
|
|
2025-05-20 18:40:07 +09:00
|
|
|
|
public void Active(bool isActive)
|
|
|
|
|
|
{
|
|
|
|
|
|
gameObject.SetActive(isActive);
|
2025-05-25 15:27:25 +09:00
|
|
|
|
|
|
|
|
|
|
if (!isActive)
|
|
|
|
|
|
{
|
|
|
|
|
|
onClose?.Invoke();
|
|
|
|
|
|
}
|
2025-05-20 18:40:07 +09:00
|
|
|
|
}
|
|
|
|
|
|
public override void AfterAwake()
|
|
|
|
|
|
{
|
|
|
|
|
|
Button_ImageSelected.onClick.AddListener(OnClickImageSelectedButton);
|
|
|
|
|
|
Toggle_AutoStart.onValueChanged.AddListener(OnAutoStartValuedChanged);
|
|
|
|
|
|
Button_LanguagePack.onClick.AddListener(OnClickLanguagePackButton);
|
2025-05-29 00:41:06 +09:00
|
|
|
|
Button_Close.onClick.AddListener(() => Active(false));
|
2025-05-20 18:40:07 +09:00
|
|
|
|
|
|
|
|
|
|
SetAnimationStyleDropdown();
|
|
|
|
|
|
SetProgressBarStyleDropdown();
|
|
|
|
|
|
SetDefaultLangaugeDropdown();
|
|
|
|
|
|
}
|
|
|
|
|
|
private void SetAnimationStyleDropdown()
|
|
|
|
|
|
{
|
|
|
|
|
|
Dropdown_AnimationStyle.ClearOptions();
|
|
|
|
|
|
var types = Enum.GetNames(typeof(AnimationStyle));
|
|
|
|
|
|
List<string> options = new List<string>();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < types.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
options.Add(types[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
Dropdown_AnimationStyle.AddOptions(options);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void SetProgressBarStyleDropdown()
|
|
|
|
|
|
{
|
|
|
|
|
|
Dropdown_ProgressBarStyle.ClearOptions();
|
|
|
|
|
|
var types = Enum.GetNames(typeof(ProgressBarStyle));
|
|
|
|
|
|
List<string> options = new List<string>();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < types.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
options.Add(types[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
Dropdown_ProgressBarStyle.AddOptions(options);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void SetDefaultLangaugeDropdown()
|
|
|
|
|
|
{
|
|
|
|
|
|
Dropdown_DefaultLangauge.ClearOptions();
|
|
|
|
|
|
var types = Enum.GetNames(typeof(DefultLanauge));
|
|
|
|
|
|
List<string> options = new List<string>();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < types.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
options.Add(types[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
Dropdown_DefaultLangauge.AddOptions(options);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void OnClickImageSelectedButton()
|
|
|
|
|
|
{
|
|
|
|
|
|
var extensions = new[] { new ExtensionFilter("Image Files", "png", "jpg", "jpeg") };
|
2025-05-29 02:50:23 +09:00
|
|
|
|
StandaloneFileBrowser.OpenFilePanelAsync("<22>̹<EFBFBD><CCB9><EFBFBD> <20><><EFBFBD><EFBFBD>", "", extensions, false, LoadImage);
|
2025-05-20 18:40:07 +09:00
|
|
|
|
}
|
|
|
|
|
|
private void OnAutoStartValuedChanged(bool isOn)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
private void OnClickLanguagePackButton()
|
|
|
|
|
|
{
|
2025-05-29 02:50:23 +09:00
|
|
|
|
var packItem = StandaloneFileBrowser.OpenFilePanel("<22><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD>", "", "", false);
|
2025-05-22 17:17:54 +09:00
|
|
|
|
|
|
|
|
|
|
if (packItem != null && packItem.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
var item = packItem[0];
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(item.Name))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
InputField_LanguagePack.text = packItem[0].Name;
|
|
|
|
|
|
}
|
2025-05-20 18:40:07 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LoadImage(IList<ItemWithStream> items)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (items != null && items.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
var item = items[0];
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(item.Name))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
using (var memoryStream = new MemoryStream())
|
|
|
|
|
|
{
|
|
|
|
|
|
using (var inputStream = item.OpenStream())
|
|
|
|
|
|
{
|
|
|
|
|
|
inputStream.CopyTo(memoryStream);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
byte[] imageData = memoryStream.ToArray();
|
|
|
|
|
|
Texture2D texture = new Texture2D(2, 2);
|
|
|
|
|
|
if (texture.LoadImage(imageData))
|
|
|
|
|
|
{
|
2025-06-30 14:10:49 +09:00
|
|
|
|
Image_Selected.enabled = true;
|
2025-05-20 18:40:07 +09:00
|
|
|
|
Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
|
|
|
|
|
|
Image_Selected.sprite = sprite;
|
2025-07-01 15:53:55 +09:00
|
|
|
|
var text = Button_ImageSelected.GetComponentInChildren<TMP_Text>();
|
|
|
|
|
|
text.enabled = false;
|
2025-05-23 09:34:37 +09:00
|
|
|
|
|
|
|
|
|
|
ratio = texture.height / (float)texture.width;
|
2025-05-20 18:40:07 +09:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-06-30 14:10:49 +09:00
|
|
|
|
Image_Selected.enabled = false;
|
2025-07-01 15:53:55 +09:00
|
|
|
|
var text = Button_ImageSelected.GetComponentInChildren<TMP_Text>();
|
|
|
|
|
|
text.enabled = true;
|
2025-05-20 18:40:07 +09:00
|
|
|
|
Debug.LogError("<22>̹<EFBFBD><CCB9><EFBFBD> <20>ε<EFBFBD> <20><><EFBFBD><EFBFBD>");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogWarning("<22>̹<EFBFBD><CCB9><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʾҽ<CABE><D2BD>ϴ<EFBFBD>.");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public AppSetting GetAppSetting()
|
|
|
|
|
|
{
|
|
|
|
|
|
var appSetting = new AppSetting();
|
|
|
|
|
|
|
2025-05-22 17:17:54 +09:00
|
|
|
|
if (Image_Selected.sprite != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var bytes = Image_Selected.sprite.texture.EncodeToPNG();
|
|
|
|
|
|
appSetting.splashImageByte = Convert.ToBase64String(bytes);
|
2025-05-23 09:34:37 +09:00
|
|
|
|
appSetting.ratio = ratio;
|
2025-05-22 17:17:54 +09:00
|
|
|
|
}
|
2025-05-20 18:40:07 +09:00
|
|
|
|
appSetting.animationStyle = Dropdown_AnimationStyle.options[Dropdown_AnimationStyle.value].text;
|
|
|
|
|
|
appSetting.progressBarStyle = Dropdown_ProgressBarStyle.options[Dropdown_ProgressBarStyle.value].text;
|
|
|
|
|
|
appSetting.autoStart = Toggle_AutoStart.isOn;
|
|
|
|
|
|
appSetting.defaultLanauge = Dropdown_DefaultLangauge.options[Dropdown_DefaultLangauge.value].text;
|
|
|
|
|
|
appSetting.languagePackPath = InputField_LanguagePack.text;
|
|
|
|
|
|
|
|
|
|
|
|
return appSetting;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void SetAppSetting(AppSetting appSetting)
|
|
|
|
|
|
{
|
2025-05-24 17:03:39 +09:00
|
|
|
|
if (appSetting == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Image_Selected.sprite = null;
|
|
|
|
|
|
Dropdown_AnimationStyle.value = 0;
|
|
|
|
|
|
Dropdown_ProgressBarStyle.value = 0;
|
|
|
|
|
|
Toggle_AutoStart.isOn = true;
|
|
|
|
|
|
Dropdown_DefaultLangauge.value = 0;
|
|
|
|
|
|
InputField_LanguagePack.text = string.Empty;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-05-24 12:51:30 +09:00
|
|
|
|
if (!string.IsNullOrEmpty(appSetting.splashImageByte))
|
2025-05-20 18:40:07 +09:00
|
|
|
|
{
|
2025-05-24 12:51:30 +09:00
|
|
|
|
var bytes = Convert.FromBase64String(appSetting.splashImageByte);
|
2025-05-20 18:40:07 +09:00
|
|
|
|
|
2025-05-24 12:51:30 +09:00
|
|
|
|
Texture2D texture = new Texture2D(2, 2);
|
|
|
|
|
|
if (texture.LoadImage(bytes))
|
|
|
|
|
|
{
|
|
|
|
|
|
Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
|
|
|
|
|
|
Image_Selected.sprite = sprite;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-05-28 13:54:19 +09:00
|
|
|
|
Dropdown_AnimationStyle.value = Dropdown_AnimationStyle.options.FindIndex(option => option.text == appSetting.animationStyle);
|
|
|
|
|
|
Dropdown_ProgressBarStyle.value = Dropdown_ProgressBarStyle.options.FindIndex(option => option.text == appSetting.progressBarStyle);
|
|
|
|
|
|
Toggle_AutoStart.isOn = appSetting.autoStart;
|
|
|
|
|
|
Dropdown_DefaultLangauge.value = Dropdown_DefaultLangauge.options.FindIndex(option => option.text == appSetting.defaultLanauge);
|
|
|
|
|
|
InputField_LanguagePack.text = appSetting.languagePackPath;
|
2025-05-20 18:40:07 +09:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|