Skip to content

C# API

The static AssetReferences facade provides lookup, streaming control, cache maintenance, and runtime events.

The selected entry’s Advanced details panel can copy its ID, a typed Get<T> snippet, or a safe TryGet<T> snippet.

Advanced entry details with buttons for copying an ID, Get snippet, and TryGet snippet

using SkywardGames.AssetReferences;
using UnityEngine;
AudioClip clip = AssetReferences.Get<AudioClip>("audio-hit-impact");
if (AssetReferences.TryGet("prefab-boss-enemy", out GameObject prefab))
{
Object.Instantiate(prefab);
}
Method Purpose
Exists(string id) Returns true when an enabled reference exists.
IsLoaded(string id) Checks whether a Direct asset is cached or Streamed asset loaded.
Get(string id) Resolves a Unity object or returns null.
Get<T>(string id) Resolves a typed Unity object or returns null.
TryGet(string id, out Object asset) Resolves an object and reports success.
TryGet<T>(string id, out T asset) Resolves a typed object and reports success.
GetAsync<T>(string id) Performs an asynchronous typed resolve.
TryGetEntry(string id, out AssetReferenceEntry entry) Gets repository metadata.
GetAll() Returns registered enabled entries.
Preload(string id) Starts loading a Streamed asset.
Release(string id) Releases a loaded Streamed asset.
ReleaseAll() Releases all loaded Streamed handles.
RebuildCache() Rebuilds runtime lookup state.

Direct entries are documented as synchronous serialized references. Streamed entries load through Addressables, with GetAsync<T> available to custom asynchronous flows. Disabled entries are skipped during cache initialization.

AssetReferences.Resolved += args =>
{
Debug.Log($"Resolved {args.Id}: {args.Asset}");
};
AssetReferences.Missing += args =>
{
Debug.LogWarning($"Missing Asset Reference: {args.Id}");
};

Runtime events include:

  • Resolved
  • StreamedLoaded
  • Released
  • Missing

It says each event receives AssetReferenceEventArgs with Id, Entry, Asset, and LoadMode.

using GameCreator.Runtime.Variables;
using SkywardGames.AssetReferences.GameCreator;
using UnityEngine;
public sealed class ReferenceVariableExample : MonoBehaviour
{
[SerializeField] private LocalNameVariables variables;
private void Start()
{
AssetReferenceVariables.Set(this.variables, "current-music", "audio-menu-theme");
if (AssetReferenceVariables.TryGet(this.variables, "current-music", out AudioClip clip))
{
Debug.Log($"Resolved {clip.name}");
}
}
}

Verify against the distributed assembly:

  • SkywardGames.AssetReferences and SkywardGames.AssetReferences.GameCreator;
  • every overload, generic constraint, return type, and null behavior;
  • AssetReferenceEntry visibility and members;
  • whether synchronous getters can initiate Streamed loading;
  • GetAsync<T>’s exact return type and failure behavior;
  • event names, static lifetime, argument type, and firing order;
  • preload/release reference counting and handle ownership;
  • RebuildCache safety and intended use; and
  • AssetReferenceVariables overloads for local and global name variables.