如何将 iPhone 的语言设置作为 Unity3D 原生功能?
我已经尝试了一切方法来找到一种通过原生 Unity3D 函数获取 iPhone 语言设置的方法。但是,我发现了两种方法,它们是:
1)使用 guiText.text = Application.systemLanguage.ToString(); 但我用中文总是得到“未知”。 2)使用 NSUserDefaults 和 PlayerPrefs。 但这不是Unity3D原生功能,当我想开发我的Android版本时,我必须做一些额外的工作。
所以,任何人都可以告诉我:有没有完美的方法来做到这一点?非常感谢!
I've try everything to find a way to get the language setting of iPhone via a native Unity3D function. however, I found two ways, those are:
1) use guiText.text = Application.systemLanguage.ToString();
But I always get 'Unknown' in Chinese language.
2) use NSUserDefaults and PlayerPrefs.
But it's not a Unity3D native function, I'll have to do some extra work when I want to develop my Android version.
So, anyone can please show me: Is there a PERFECT way to do that? Thank you very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道什么是统一,但是 NSLocale 或 CFLocale 对你有帮助吗? NSLocale 基于 Objective-C,因此更容易使用:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSLocale_Class/Reference/Reference.html
CFLocale 是基于 c 的,因此它的有点棘手,但提供了更多功能:
http://developer.apple.com/library/ mac/#documentation/CoreFoundation/Reference/CFLocaleRef/Reference/reference.html
如果您正在查找当前的语言代码,您应该能够获取当前的语言环境并进行检查。
I don't know what unity is, but would NSLocale or CFLocale help you? NSLocale is objective-c based and thus a bit easier to use:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSLocale_Class/Reference/Reference.html
CFLocale is c-based, so its a bit more tricky, but offers more functionality:
http://developer.apple.com/library/mac/#documentation/CoreFoundation/Reference/CFLocaleRef/Reference/reference.html
If you are looking for the current language code you should be able to grab the current locale and inspect that.