Working With Assets in Game
This page deals only with Assets on a game level. To learn about assets on a player lavel, check out Working With Assets for Player in Game how-to

Retrieve Assets

To start retrieving assets you can run following:
Unity
1
int count = 10;
2
LootLockerSDKManager.GetAssetListWithCount(count, (response) =>
3
{
4
if (response.success)
5
{
6
Debug.Log("Successfully retrieved " + response.assets.Length + " assets");
7
}
8
else
9
{
10
Debug.Log("Error retrieving assets");
11
}
12
});
Copied!
After the initial method has completed retrieving assets you can call this method to get more:
Unity
1
LootLockerSDKManager.GetAssetNextList(count, (response) =>
2
{
3
if (response.success)
4
{
5
Debug.Log("Successfully retrieved second batch of " + response.assets.Length + " assets");
6
}
7
else
8
{
9
Debug.Log("Error retrieving assets");
10
}
11
});
Copied!
If you want to retrieve all you asets you can keep calling the method until you stop receiving assets.
After finishing retrieving the assets you need, it's best practice to run the following code, as if you try to get assets later, you might start from your previous last retrieved asset.
Unity
1
LootLockerSDKManager.ResetAssetCalls();
Copied!

Retrieve Assets With Filter

Unity
1
int count = 10;
2
List<LootLocker.LootLockerEnums.AssetFilter> filter = new List<LootLocker.LootLockerEnums.AssetFilter>() { LootLocker.LootLockerEnums.AssetFilter.nonpurchasable };
3
4
LootLockerSDKManager.GetAssetListWithCount(count, (response) =>
5
{
6
if (response.success)
7
{
8
Debug.Log("Successfully retrieved " + response.assets.Length + " assets");
9
10
}
11
else
12
{
13
Debug.Log("Error retrieving assets");
14
}
15
}, filter);
Copied!

Retrieve Assets by IDs

If you already know the IDs of the assets you wish to get, you can use this method to retrieve them specifically.
Unity
1
string[] list = new string[] { "8111" };
2
3
LootLockerSDKManager.GetAssetsById(list, (response) =>
4
{
5
if (response.success)
6
{
7
Debug.Log("Successfully retrieved " + response.assets.Length + " assets");
8
Debug.Log("First Asset ID: " + response.assets[0].id);
9
10
}
11
else
12
{
13
Debug.Log("Error retrieving assets");
14
}
15
});
Copied!

Retrieve Favorite Assets

Unity
1
LootLockerSDKManager.ListFavouriteAssets((response) =>
2
{
3
if (response.success)
4
{
5
Debug.Log("Successfully retrieved " + response.favourites.Length + " assets");
6
7
if (response.favourites.Length > 0)
8
{
9
Debug.Log("First Asset ID: " + response.favourites[0]);
10
} else
11
{
12
Debug.Log("No favourite assets");
13
}
14
}
15
else
16
{
17
Debug.Log("Error retrieving assets");
18
}
19
});
Copied!

Add Favorite Asset

Unity
1
LootLockerSDKManager.AddFavouriteAsset("8111", (response) =>
2
{
3
if (response.success)
4
{
5
Debug.Log("Successfully favourited asset");
6
}
7
else
8
{
9
Debug.Log("Error favouriting asset");
10
}
11
});
Copied!

Remove Favorite Asset

Unity
1
LootLockerSDKManager.RemoveFavouriteAsset("8111", (response) =>
2
{
3
if (response.success)
4
{
5
Debug.Log("Successfully removed favourite asset");
6
}
7
else
8
{
9
Debug.Log("Error removing favourite asset");
10
}
11
});
Copied!
Last modified 1mo ago