gpt4 book ai didi

unity-game-engine - Unity3d 使用 CreateSpecificCulture

转载 作者:行者123 更新时间:2023-12-03 00:23:07 25 4
gpt4 key购买 nike

为了在 Unity3d 应用程序中获取文化信息,我编写了一些代码:

public static System.Globalization.CultureInfo GetCultureInfo()
{
if (cultureInfo == null)
cultureInfo = System.Globalization.CultureInfo
.CreateSpecificCulture(Localization.Data.Locale);

return cultureInfo;
}

当我在编辑器中运行应用程序时,它工作正常。如果我将应用程序构建为网络并运行,那么我会收到异常

at System.Security.SecurityManager.ThrowException (System.Exception ex) 
[0x00000] in <filename unknown>:0

为什么它在网络播放器中不起作用?

最佳答案

如果您查看 WebPlayer 使用的 mscorlib 中的方法 CultureInfo.CreateSpecificCulture()(例如使用 ILSpy),您将看到它被标记为 SecurityCritical(您可以阅读有关 .Net 安全性的更多信息 herehere )

[安全关键]
公共(public)静态 CultureInfo CreateSpecificCulture(字符串名称)

而且,据我所知,游戏中的所有代码都被视为“透明”,因此不允许调用“安全关键”代码。

此外,如果您检查 this page该方法被标记为 WebPlayer 不支持。

关于unity-game-engine - Unity3d 使用 CreateSpecificCulture,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22319780/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com