Yongyi
Yongyi

Reputation: 345

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:

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

Upvotes: 4

Views: 456

Answers (1)

Yongyi
Yongyi

Reputation: 345

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

Upvotes: 1

Related Questions