amazon-web-services - 在 Unity3d 中创建 AmazonGameLiftClient 失败
问题描述
我使用以下代码在 Unity3d 中创建 GameClient:
AmazonGameLiftClient client =
new AmazonGameLiftClient("accessKeyId",
"accessKey",
RegionEndpoint.CNNorth1);
以上代码是 Awake() 中的第一行,没有任何其他前导代码。
我得到以下错误:
NullReferenceException: Object reference not set to an instance of an object
Amazon.CSMSection.get_CSMEnabled ()
Amazon.Util.CSMConfig.Configure (Amazon.CSMSection section)
Amazon.Util.Internal.RootConfig..ctor ()
Amazon.AWSConfigs..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Amazon.AWSConfigs
Amazon.Runtime.ClientConfig..ctor ()
Amazon.GameLift.AmazonGameLiftConfig..ctor ()
Amazon.GameLift.AmazonGameLiftClient..ctor (System.String awsAccessKeyId, System.String awsSecretAccessKey, Amazon.RegionEndpoint region)
有什么我忘了做的吗?我认为根本原因是我没有将 app.config 放在正确的位置。所以 AWS SDK 没有正确初始化,但我还没有找到任何使用 Unity3d 作为 Amazon GameLift 客户端的教程 :(
我的环境:
- 操作系统:Mac OS X 10.14.1
- Unity3d:2018.2.12f1
- AWS 开发工具包核心:3.3.29.10(.net35)
- AWS 开发工具包 GameLift:3.3.12.29(.net35)
更新: AWS SDK 依赖于 Unity3d 项目中似乎不可用的 System.ConfigurationManager。这似乎是 NullReferenceException 的根本原因。
解决方案
请参考这个答案,它完全解决了这个问题。
推荐阅读
- linux - 如何检测 linux 端口是否被 Go 中的进程绑定?
- ios - 表格单元格中的 UIswitch 重复问题
- azure - Azure Service Fabric 中的主节点和非主节点有什么区别?
- node.js - Oauth2 Flow , Authorize 和 Authorization Grant 的区别
- android - 如何分析 btsnoop_hci.log (bluetooth/android/wireshark)
- mql4 - 重新 MQL4 代码限制打开符号的数量
- php - 在 PHP 中的 zoho api v2 中插入记录
- postgresql - Postgres - UNION ALL 与 INSERT INTO 哪个更好?
- php - 在 PHP 如何更新下拉列表值
- wordpress - Woocommerce 产品类别模板