先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
102 lines
3.5 KiB
C#
102 lines
3.5 KiB
C#
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using asap.core;
|
|
using cfg;
|
|
using game;
|
|
using GameCore;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class SelectlanguagePopupPanel : MonoBehaviour
|
|
{
|
|
public Button btn_close;
|
|
public Button btn_mask;
|
|
|
|
public GameObject item;
|
|
public Transform content;
|
|
public Button btn_sure;
|
|
int language;
|
|
List<Toggle> toggles = new List<Toggle>();
|
|
private void Awake()
|
|
{
|
|
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
|
btn_mask = transform.Find("mask").GetComponent<Button>();
|
|
content = transform.Find("root/panel_list/ScrollView/Viewport/Content").GetComponent<Transform>();
|
|
btn_sure = transform.Find("root/btn_sure/btn_green").GetComponent<Button>();
|
|
|
|
}
|
|
private void Start()
|
|
{
|
|
item.SetActive(false);
|
|
btn_close.onClick.AddListener(() => { UIManager.Instance.DestroyUI(UITypes.SelectlanguagePopupPanel); });
|
|
btn_mask.onClick.AddListener(() => { UIManager.Instance.DestroyUI(UITypes.SelectlanguagePopupPanel); });
|
|
IUIService uiService = GContext.container.Resolve<IUIService>();
|
|
List<LanguageConfig> _dataList = GContext.container.Resolve<cfg.Tables>().TbLanguageConfig.DataList;
|
|
GameObject ru = null;
|
|
for (int i = 0; i < _dataList.Count; i++)
|
|
{
|
|
GameObject go = Instantiate(item, content);
|
|
go.SetActive(true);
|
|
Image image = go.transform.Find("img_languagelist").GetComponent<Image>();
|
|
uiService.SetImageSprite(image, _dataList[i].LanImg);
|
|
var i1 = i;
|
|
Toggle toggle = go.GetComponent<Toggle>();
|
|
toggle.onValueChanged.AddListener((isOn) =>
|
|
{
|
|
if (isOn)
|
|
{
|
|
language = i1;
|
|
}
|
|
});
|
|
toggles.Add(toggle);
|
|
if (_dataList[i].ID == "ru")
|
|
{
|
|
ru = go;
|
|
}
|
|
}
|
|
if (ChannelManager.IsRustoreStore && ru != null)
|
|
{
|
|
ru.transform.SetAsFirstSibling();
|
|
}
|
|
language = LocalizationMgr.LanguageIndex;
|
|
for (int i = 0; i < toggles.Count; i++)
|
|
{
|
|
toggles[i].isOn = language == i;
|
|
}
|
|
btn_sure.onClick.AddListener(OnBtnLanguage);
|
|
}
|
|
|
|
private async void OnBtnLanguage()
|
|
{
|
|
if (LocalizationMgr.LanguageIndex != language)
|
|
{
|
|
string languagePack = LocalizationMgr.languagePackList[language];
|
|
ILoadResourceService loadResourceService = GContext.container.Resolve<ILoadResourceService>();
|
|
bool isInit = await loadResourceService.Load(languagePack);
|
|
if (!isInit)
|
|
{
|
|
Debug.Log($"Load language pack {languagePack} failed. download");
|
|
var panel = await UIManager.Instance.ShowUINotLoading(UITypes.DownLoadPopupPanel);
|
|
panel.GetComponent<DownLoadPopupPanel>().SetBtn(() =>
|
|
{
|
|
SetLanguage();
|
|
}, () =>
|
|
{
|
|
UIManager.Instance.DestroyUI(UITypes.SelectlanguagePopupPanel);
|
|
});
|
|
}
|
|
else
|
|
{
|
|
SetLanguage();
|
|
}
|
|
//下载多语言包
|
|
}
|
|
|
|
}
|
|
void SetLanguage()
|
|
{
|
|
LocalizationMgr.SetLanguageAsync(language);
|
|
UIManager.Instance.DestroyUI(UITypes.SelectlanguagePopupPanel);
|
|
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_108"));
|
|
}
|
|
} |