简体   繁体   中英

Failed to create AmazonGameLiftClient in Unity3d

I use below code to create GameClient in Unity3d:

AmazonGameLiftClient client = 
        new AmazonGameLiftClient("accessKeyId",
                                 "accessKey",
                                  RegionEndpoint.CNNorth1);

Above code is the first line in Awake(), no any other leading codes.

I get below error:

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)

Is there anything I forgot to do? I assume the root cause is I do not put app.config in the correct place. So AWS SDK does not init correctly, but I have not found any tutorial for using Unity3d as Amazon GameLift client :(

My Environment:

  • OS: Mac OS X 10.14.1
  • Unity3d: 2018.2.12f1
  • AWS SDK Core: 3.3.29.10(.net35)
  • AWS SDK GameLift: 3.3.12.29(.net35)

Update: The AWS SDK relies on System.ConfigurationManager which seems not available in Unity3d projects. It seems the root cause of the NullReferenceException.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM