This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "Stmt1432372934255", | |
"Action": [ | |
"dynamodb:DeleteItem", | |
"dynamodb:GetItem", | |
"dynamodb:PutItem", | |
"dynamodb:Scan", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Amazon; | |
using Amazon.CognitoIdentity; | |
using Amazon.DynamoDBv2; | |
using Amazon.DynamoDBv2.DataModel; | |
using Amazon.DynamoDBv2.DocumentModel; | |
using Amazon.DynamoDBv2.Model; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using Amazon.DynamoDBv2.DataModel; | |
namespace Assets.CharacterCreatorAWSDynamoDB.Scripts | |
{ | |
[DynamoDBTable("CharacterCreator")] | |
public class CharacterEntity | |
{ | |
[DynamoDBHashKey] // Hash key. | |
public string CharacterID { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string cognitoIdentityPoolString; | |
private CognitoAWSCredentials credentials; | |
private IAmazonDynamoDB _client; | |
private DynamoDBContext _context; | |
private List<CharacterEntity> characterEntities = new List<CharacterEntity>(); | |
private int currentCharacterIndex; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private DynamoDBContext Context | |
{ | |
get | |
{ | |
if (_context == null) | |
_context = new DynamoDBContext(_client); | |
return _context; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void LoadCharacter(CharacterEntity characterEntity) | |
{ | |
// Update the selected body component values stored as field values | |
selectedBody = characterEntity.BodySpriteName; | |
selectedFace = characterEntity.FaceSpriteName; | |
selectedHair = characterEntity.HairSpriteName; | |
selectedShirt = characterEntity.ShirtSpriteName; | |
selectedPants = characterEntity.PantsSpriteName; | |
selectedShoes = characterEntity.ShoesSpriteName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
createOperation.onClick.AddListener(CreateCharacterInTable); | |
refreshOperation.onClick.AddListener(FetchAllCharactersFromAWS); | |
NextCharacterButton.onClick.AddListener(CycleNextCharacter); | |
PrevCharacterButton.onClick.AddListener(CyclePrevCharacter); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void FetchAllCharactersFromAWS() | |
{ | |
resultText.text = "\n***LoadTable***"; | |
Table.LoadTableAsync(_client, "CharacterCreator", (loadTableResult) => | |
{ | |
if (loadTableResult.Exception != null) | |
{ | |
resultText.text += "\n failed to load characters table"; | |
} | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void CreateCharacterInTable() | |
{ | |
var newCharacter = new CharacterEntity | |
{ | |
CharacterID = Guid.NewGuid().ToString(), | |
BodySpriteName = selectedBody, | |
FaceSpriteName = selectedFace, | |
ShirtSpriteName = selectedShirt, | |
HairSpriteName = selectedHair, | |
PantsSpriteName = selectedPants, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Setup our credentials which will use our Cognito identity pool to hand us short-term session credentials, | |
// giving us access to what we have provided access to with our IAM role policies, in this case, access to our | |
// DynamoDB table. | |
credentials = new CognitoAWSCredentials(cognitoIdentityPoolString, RegionEndpoint.USEast1); | |
credentials.GetIdentityIdAsync(delegate(AmazonCognitoIdentityResult<string> result) | |
{ | |
if (result.Exception != null) | |
{ | |
Debug.LogError("exception hit: " + result.Exception.Message); | |
} |
OlderNewer