配置Language Selection脚本的语言类型的按钮。(估计是观察者模式写的)
法一:
1.text文本直接绑定I2 Localize脚本(使用固定的句子)使用其他上网技术可以自动翻译或者手动翻译。
法二:(对话,短暂显示)
1.编辑器扩展中打开插件的.asset的翻译库。添加需要翻译的句子。
2.脚本调用对应的文本进行拼接即可。
Eg:添加.asset库中名为“Your”的翻译句子“your phone number is”一条。
脚本调用:
using I2.Loc;
...
LocalizedString realText = "Your";
textControl.text = realText+" 123456789.";
...
或者:
I2.Loc.LocalizedString str = "banlance";
text.text=str;
法三:(多组字段,长久显示)
将可能的字段全部加入到翻译库中,以名字区分,然后这样调用:
Item.nickname.transform.GetComponent<I2.Loc.Localize>().SetTerm(“name”);
参考网址:https://blog.csdn.net/baozhongcheng/article/details/77460436
tips:带变量的解决办法。
在翻译的句子中使用 {[amount]}格式,将变量放到括号中,例如那个amount是变量即字段。eg:我有{[amount]}个硬币;
此时需要添加localizationParamsManager脚本例如;
如果使用代码修改只需要修改脚本中,字段对应的value即可;
eg:
transform.GetComponent<localizationParamsManager>().SetParameterValue("amount", "10");
需要设置文本内容同时设置字体,可以在i2Localize脚本中添加main中设置文本,secondary设置字体即可。