- 文字顯示不出來時直接在腳本中找到組件顯示出來,直接打中文即可,如果在
這裏邊寫的話,就在Text框裏直接寫Key值就行,檢查Text框是否夠大
- 更換圖片時,原圖片的Source Image要先刪除掉,然後換上加載出來的圖片,圖片加載路徑要從Resources後開始寫,例如
AvatarImg = transform.Find("MainPage/protagonist/AvatarImg").GetComponent<Image>();
AvatarImg.sprite=Resources.Load<Sprite>("textures/UItextures/RoleUIAtlas/"+Canad.HeroPrefabName);
- 判斷非法字符
例如這個方法
private void OnCreateSucessText()
{
if (selectRole)
{
if (nameIDIpt.text.Length >= 5 && nameIDIpt.text.Length <= 8)
{
Regex regex = new Regex(@"^[A-Za-z0-9\u4e00-\u9fa5]+$");
if (regex.IsMatch(nameIDIpt.text))
{
IsCreateHerosucess = true;
}
else
{
GameEntry.UI.OpenDialog(new DialogParams()
{
Mode = 1,
Title = GameEntry.Localization.GetString("Login.Error"),
Message = GameEntry.Localization.GetString("CreatRole.errorname"),
});
}
}
else
{
GameEntry.UI.OpenDialog(new DialogParams()
{
Mode = 1,
Title = GameEntry.Localization.GetString("Login.Error"),
Message = GameEntry.Localization.GetString("CreatRole.errorName"),
});
}
}
else
{
GameEntry.UI.OpenDialog(new DialogParams()
{
Mode = 1,
Title = GameEntry.Localization.GetString("Login.Error"),
Message = GameEntry.Localization.GetString("CreatRole.RolenullError"),
});
}
}