FetchAllUploadedContent (Unity)
- Declaration
public static void FetchAllUploadedContent(Action<List<CavrnusRemoteContent>> onCurrentContentArrived)
- Description
Gives you a list of all the available content on your Cavrnus domain. Returns a list of type CavrnusRemoteContent. This is useful when displaying a menu of uploaded file options to your users.
- Sample
using CavrnusSdk.API;
using System.IO;
using UnityEngine;
public class PlantsFilePicker : MonoBehaviour
{
public PlantPickerUi pickerUi;
// Start is called before the first frame update
void Start()
{
//Don't bother fetching content list until we are authenticated
CavrnusFunctionLibrary.AwaitAuthentication(auth => RefreshLibraryContent());
}
public void RefreshLibraryContent()
{
CavrnusFunctionLibrary.FetchAllUploadedContent(allContent =>
{
//Remove all the old options, in case one got deleted
pickerUi.Clear();
foreach (var item in allContent)
{
//We only want fbx files
if (!Path.GetExtension(item.FileName).ToLowerInvariant().Equals(".fbx"))
continue;
//We only want files tagged as plants. We added this tag when we called UploadContent
if (!item.Tags.ContainsKey("FileType") || item.Tags["FileType"] != "Plant")
continue;
pickerUi.ShowContentOption(item);
}
});
}
}