Failed to create AmazonGameLiftClient in Unity3d

440 views Asked by At

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.

1

There are 1 answers

0
Yongyi On BEST ANSWER

Please refer to this answer, it completely solves this question.