When fetching metadata by tags, a key will supersede the tag, so if you want to search by tags it’s best to avoid using keys and vice versa. When fetching metadata by tags you will get all metadata on that object with the same corresponding tag.
// Create an array of sources and keys that we want to fetchLootLockerMetadataSourceAndKeys[] sourcesAndKeys =newLootLockerMetadataSourceAndKeys[]{newLootLockerMetadataSourceAndKeys { source =LootLockerMetadataSources.currency, id ="01J7S0CED5K0THCB1ENN9XKQWZ", keys =newstring[] { "icon" } },newLootLockerMetadataSourceAndKeys { source =LootLockerMetadataSources.catalog_item, id ="01J9RE51T32WNXSQADNJ5RGQCX", keys =newstring[] { "icon","featured" } }};// Base64 can be set to content_type "application/x-redacted", use this to avoid accidentally fetching large data filesbool ignoreFiles =true;LootLockerSDKManager.GetMultisourceMetadata(sourcesAndKeys, (response) =>{if (response.success) { // Handle the received metadata differently depending on the use casesforeach (var entry inresponse.Metadata) { // Currencyif (entry.source==LootLockerMetadataSources.currency) { // Get the first entry as a base64 (file), this is an image so we convert it to a sprite to be displayedLootLockerMetadataBase64Value base64String =null;entry.entries[0].TryGetValueAsBase64(out base64String);byte[] imageBytes =Convert.FromBase64String(base64String.content);Texture2D tex =newTexture2D(291,302);tex.LoadImage(imageBytes);tex.filterMode=FilterMode.Point;Sprite sprite =Sprite.Create(tex,newRect(0.0f,0.0f,tex.width,tex.height),newVector2(0.5f,0.5f),100.0f); // Add your own code here to display the sprite } // Catalog Itemif (entry.source==LootLockerMetadataSources.catalog_item) { // Multiple keys requested: loop through to find the correct oneforeach (var catalogItemMetadata inentry.entries) { // Handle the imageif (catalogItemMetadata.type==LootLockerMetadataTypes.Base64) { // Look above in how LootLockerMetadataSources.currency is handled to see how to handle an image } // Handle a boolif (catalogItemMetadata.type==LootLockerMetadataTypes.Bool) {bool featured =catalogItemMetadata.TryGetValueAsBool(out featured); // Add your own code here to make us of the returned bool value } } } } }else { // If it failed, output the error to the consoleDebug.Log(response.errorData.message); }}, ignoreFiles);
Check out our SDK for more ways of handling the received metadata entries.