/* * * Execute a PlayFab Cloud Script function to update the group entity object data to the * updated CSV. Title-level data should not be changed directly from the client. * * @param dataobj: the updated CSV; the Cloud Script function sets the entity group object data to * this value. * @param item_id: ItemID of the item that was either added or removed * */ private void UpdateObject(string dataobj, bool adding_item, string item_id) { PlayFab.DataModels.EntityKey entity = new PlayFab.DataModels.EntityKey { Id = LoginClass.getPlayerEntityKeyId(), Type = LoginClass.getPlayerEntityKeyType() }; List <PlayFab.DataModels.SetObject> ObjList = new List <PlayFab.DataModels.SetObject>(); ObjList.Add( new PlayFab.DataModels.SetObject { ObjectName = "wishlist", DataObject = dataobj } ); var request = new PlayFab.DataModels.SetObjectsRequest { Entity = entity, Objects = ObjList }; PlayFabDataAPI.SetObjects(request, result => { if (adding_item) { StoreSetup.SetUpStore(item_id, false); } else { StoreSetup.SetUpStore(item_id, true); } }, error => { Debug.LogError(error.GenerateErrorReport()); }); }
/* * * If the wish list does not exist, we create an entity object for the player. * */ private static void CreateEntityWishList() { PlayFab.DataModels.EntityKey entity = new PlayFab.DataModels.EntityKey { Id = LoginClass.getPlayerEntityKeyId(), Type = LoginClass.getPlayerEntityKeyType() }; /* SetObjects takes in a list of type SetObject. These will contain the objects that we want to set. */ List <PlayFab.DataModels.SetObject> ObjList = new List <PlayFab.DataModels.SetObject>(); /* * We will add an object of type wishlist. The DataObject is empty because we are initializing the entity object, * as it does not exist. We do not have any ItemId's to add to the wish list yet. */ ObjList.Add( new PlayFab.DataModels.SetObject { ObjectName = "wishlist", DataObject = "" } ); var request = new PlayFab.DataModels.SetObjectsRequest { Entity = entity, Objects = ObjList }; /* Call PlayFab SetObjects to set the object data for the player entity. */ PlayFabDataAPI.SetObjects(request, result => { /* The title player now has a wishlist object. */ Debug.Log("Set object successful"); }, error => { Debug.LogError(error.GenerateErrorReport()); }); }