首页 > 解决方案 > 在 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 客户端的教程 :(

我的环境:

更新: AWS SDK 依赖于 Unity3d 项目中似乎不可用的 System.ConfigurationManager。这似乎是 NullReferenceException 的根本原因。

标签: amazon-web-servicesunity3daws-sdkaws-sdk-netamazon-gamelift

解决方案


请参考这个答案,它完全解决了这个问题。


推荐阅读