目录
I2 localization简单介绍
I2 localization是一个Unity3D可用的本地化插件。
没有找到比较系统的介绍,一句话说,就是用来改语言的。
购买地址
https://assetstore.unity.com/packages/tools/localization/i2-localization-14884?aid=1101l4nxF
要$45,公司让学习一下,就简单学一下,我自己就不买了
简单使用介绍
语言管理器
添加组件之后会有这样的显示,language这里是设置对应的语言的,下面有一个小的搜索框,可以搜索其他语言,设置之后terms下面可以看到相应的变化。
Terms相当于词条,下面是预置好的一些词条,比如这个游戏登录的
可以直接在这里点加号进行添加,可以在一开始设置key的时候用/,比如上面的title就是hall/login/title,这样在后面找起来比较方便,就像拥有了一个目录的模式。
场景中的UI设置
内容
给场景中的UI添加一个Localize组件,这里的Target是对应UI的类型,Main选择对应的Term,就会看到之前设置好的词条。Open Source选择刚才设置了语言管理器的预置体拖进去。这里可以设置不同语言的内容。
字体
组件的secondary的term可以选择Font类型,定义了不同语言的字体,这个term也是可以添加在资源库里面的:
样式
I2 Localization doesn’t provide a way to adjust the size directly as that could make more confusing the inspector (that is already crowdy) by introducing another setting per-language.
I2 Localization不能直接修改不同语言对应的字体大小,但是可以通过下面的方式(富文本)来修改。
添加脚本
选择Tools下面的Script,点Build Script with。。。就可以在脚本里面看到生成了相应的代码。
【原谅我这个花花的马赛克,毕竟公司代码,不能随便泄露,还是要谨慎点好】
后面的估计还没写好,找不到了,算了,以后再说。。
相关API
http://www.inter-illusion.com/assets/I2LocalizationManual/CommonlyusedScriptAPIs.html
设置当前语言
// Change the Current Language
I2.Loc.LocalizationManager.CurrentLanguage = "English";
I2.Loc.LocalizationManager.CurrentLanguage = "English (Canada)"; //Language and Variant
I2.Loc.LocalizationManager.CurrentLanguage = "English Canada"; //another way of setting it
// or
I2.Loc.LocalizationManager.CurrentLanguageCode = "en";
I2.Loc.LocalizationManager.CurrentLanguageCode = "en-US";
I2.Loc.LocalizationManager.CurrentLanguageCode = "en-CA";
注意点
When setting a language without a variant (e.g. “English”), the plugin changes to the first “English” language in the language Source list (e.g. “English (Canad