【本地化】GM界面不再翻译

dev_chengFeng
gaoxin 2021-04-09 18:20:07 +08:00
parent e55e8b51ee
commit 8e677abe4e
2 changed files with 13 additions and 42 deletions

View File

@ -23,26 +23,7 @@ local function createPanel(uiConfig, parent)
recTransform.anchoredPosition3D = Vector3.New(0, 0, 0)
recTransform.sizeDelta = Vector2.New(0, 0)
transform.localRotation = Quaternion.identity
if GetCurLanguage()~=0 then
local textArr=gameObject:GetComponentsInChildren(typeof(UnityEngine.UI.Text),true);
for i = 0, textArr.Length-1 do
local textStr=textArr[i].text
textArr[i].text=GetLanguageStrById(textStr)
if GetCurLanguage() == 2 and textArr[i].font and (string.find(textArr[i].font.name,"kaiu",1) or string.find(textArr[i].font.name,"FZJinLS",1)) then
textArr[i].font = Util.LoadFont()
end
end
local imageArr=gameObject:GetComponentsInChildren(typeof(UnityEngine.UI.Image),true);
for i = 0, imageArr.Length-1 do
if imageArr[i].sprite then
local imgStr=imageArr[i].sprite.name
if string.sub(imgStr,-3)=="_zh" then
imageArr[i].sprite=Util.LoadSprite(imgStr)
Log("资源名称:"..imgStr)
end
end
end
end
UIManager.DoLanguageCheck(gameObject)
return gameObject
end

View File

@ -612,27 +612,8 @@ function UIManager.CreatePanel(uiConfig, parent)
recTransform.anchoredPosition3D = Vector3.New(0, 0, 0)
recTransform.sizeDelta = Vector2.New(0, 0)
transform.localRotation = Quaternion.identity
if GetCurLanguage()~=0 then
local textArr=gameObject:GetComponentsInChildren(typeof(UnityEngine.UI.Text),true);
for i = 0, textArr.Length-1 do
local textStr=textArr[i].text
textArr[i].text=GetLanguageStrById(textStr)
if GetCurLanguage() == 2 and textArr[i].font and (string.find(textArr[i].font.name,"kaiu",1) or string.find(textArr[i].font.name,"FZJinLS",1)) then
textArr[i].font = Util.LoadFont()
end
end
local imageArr=gameObject:GetComponentsInChildren(typeof(UnityEngine.UI.Image),true);
for i = 0, imageArr.Length-1 do
if imageArr[i].sprite then
local imgStr=imageArr[i].sprite.name
if string.sub(imgStr,-3)=="_zh" then
imageArr[i].sprite=Util.LoadSprite(imgStr)
Log("资源名称:"..imgStr)
end
end
end
end
-- 多语言处理
this.DoLanguageCheck(gameObject)
return gameObject
end
@ -664,10 +645,19 @@ function UIManager.CreatePanelAsync(uiConfig, parent, func)
end)
end
-- 不翻译的界面
local ExceptPrefabList = {
"GMPanel"
}
-- 根据语言对界面显示进行修改
function UIManager.DoLanguageCheck(gameObject)
-- 判断是否需要翻译
if table.indexof(ExceptPrefabList, gameObject.name) then
return
end
if GetCurLanguage()~=0 then
local textArr=gameObject:GetComponentsInChildren(typeof(LanguageText),true);
local textArr=gameObject:GetComponentsInChildren(typeof(UnityEngine.UI.Text),true);
for i = 0, textArr.Length-1 do
local textStr=textArr[i].text
textArr[i].text=GetLanguageStrById(textStr)