Astra Unity 2.6.6
Astra Unity Plugin
Examples/Catalog/QueryingCatalog.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Astra.Examples {
public class QueryingCatalog : MonoBehaviour {
public ulong startingGuid = 0;
private HashSet<ulong> seen = new HashSet<ulong>(); //maintain a list to prevent recursive looping
private HashSet<string> discoveredAssetGuids = new HashSet<string>();
void Start () {
Fetch(startingGuid);
}
public Net.GetAssetCategoryJob Fetch(ulong catId)
{
//avoid recursive loops
if(seen.Contains(catId))
{
return null;
}
seen.Add(catId);
bool withThumbnails = true;
var job = Catalog.GetAssetCategory((long)catId, withThumbnails);
Texture2D icon = null;
//if we don't care about the thumbnails we could just use OnJobDone instead
job.OnJobDoneMain += (_) =>
{
//result is a sorted dictionary keyed on the id of the category with the value being more data
var result = job.GetResult();
foreach(var kvp in result)
{
var assetCategory = kvp.Value;
if(withThumbnails){
icon = assetCategory.icon;
}
Astra.Logger.Log("Category Id: " + kvp.Key + " name: " + assetCategory.title + " visible: " + assetCategory.visible);
//This asset list is the assets directly IN this category, not all child assets
for(int i=0;i<assetCategory.assetGUIDs.Count;i++)
{
var guid = assetCategory.assetGUIDs[i];
//we only get the guid, no other info
Astra.Logger.Log("Asset: " + i + " => " + guid);
discoveredAssetGuids.Add(guid);
}
for(int i=0;i<assetCategory.childrenIDs.Count;i++)
{
var guid = assetCategory.childrenIDs[i];
Astra.Logger.Log("Child cat: " + i + " => " + guid);
Fetch(guid);
}
}
};
return job;
}
}
}
Handles Astra logging messages in C# allowing filtering and redirection
Definition: Logger.cs:15
static void Log(object message)
A one-to-one with UnityEngine.Debug.Log, records as Info level
Definition: Logger.cs:99
Definition: AnimatingAnAvatar.cs:9
Definition: AnimationManager.cs:10