assembly-definitions
Assembly definition management — when to create asmdefs, reference rules, Editor/Runtime/Test separation, platform filters, compilation speed optimization.
Addressables asset loading — LoadAssetAsync, handle lifecycle, labels, remote catalogs, memory management. Use for asset loading and memory optimization.
$ npx -y skills add XeldarAlz/everything-claude-unity --skill addressables --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/addressablesContext preview
The summary Claude sees to decide when to auto-load this skill.
Addressables asset loading — LoadAssetAsync, handle lifecycle, labels, remote catalogs, memory management. Use for asset loading and memory optimization.
name: addressables description: "Addressables asset loading — LoadAssetAsync, handle lifecycle, labels, remote catalogs, memory management. Use for asset loading and memory optimization." globs: ["**/Addressable*.cs", "**/*Address*"]
1. Install via Package Manager: `com.unity.addressables` 2. Mark assets as Addressable in the Inspector checkbox 3. Organize into Groups (local, remote, by scene, by feature) 4. Assign Labels for batch loading (e.g., "level1", "enemies", "ui")
Groups: Local_Static -- Core assets, always available (shaders, essential UI) Local_Dynamic -- Assets that change between builds Remote_Levels -- Level-specific assets, downloaded on demand Remote_Characters -- Character models/animations
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
public class AddressableLoader : MonoBehaviour
{
[SerializeField] private AssetReference prefabReference;
private AsyncOperationHandle<GameObject> _loadHandle;
private GameObject _instance;
public async void LoadAndInstantiate()
{
_loadHandle = Addressables.LoadAssetAsync<GameObject>(prefabReference);
await _loadHandle.Task;
if (_loadHandle.Status == AsyncOperationStatus.Succeeded)
{
_instance = Instantiate(_loadHandle.Result);
}
else
{
Debug.LogError($"Failed to load addressable: {_loadHandle.OperationException}");
}
}
// CRITICAL: Always release handles to prevent memory leaks
private void OnDestroy()
{
if (_loadHandle.IsValid())
{
Addressables.Release(_loadHandle);
}
if (_instance != null)
{
Destroy(_instance);
}
}
}public class AddressableInstantiator : MonoBehaviour
{
[SerializeField] private AssetReference prefabReference;
private AsyncOperationHandle<GameObject> _instanceHandle;
public async void SpawnObject(Vector3 position, Quaternion rotation)
{
_instanceHandle = Addressables.InstantiateAsync(prefabReference, position, rotation);
await _instanceHandle.Task;
if (_instanceHandle.Status != AsyncOperationStatus.Succeeded)
{
Debug.LogError("Failed to instantiate addressable");
}
}
private void OnDestroy()
{
// ReleaseInstance destroys the object AND releases the handle
if (_instanceHandle.IsValid())
{
Addressables.ReleaseInstance(_instanceHandle);
}
}
}Every `LoadAssetAsync` or `InstantiateAsync` call returns a handle that MUST be released.
1. **Every load must have a matching release.** No exceptions. 2. **Track all handles.** Store them in fields or a list. 3. **Release on destroy.** Use OnDestroy or a dedicated cleanup method. 4. **Check IsValid() before releasing.** Prevents double-release errors.
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
public class AddressableManager : MonoBehaviour
{
private readonly List<AsyncOperationHandle> _handles = new();
public AsyncOperationHandle<T> LoadAsset<T>(object key)
{
var handle = Addressables.LoadAssetAsync<T>(key);
_handles.Add(handle);
return handle;
}
public AsyncOperationHandle<GameObject> InstantiateAsset(AssetReference reference,
Vector3 position = default, Quaternion rotation = default)
{
var handle = Addressables.InstantiateAsync(reference, position, rotation);
_handles.Add(handle);
return handle;
}
public void ReleaseAll()
{
foreach (var handle in _handles)
{
if (handle.IsValid())
{
Addressables.Release(handle);
}
}
_handles.Clear();
}
private void OnDestroy()
{
ReleaseAll();
}
}Load multiple assets sharing a label in a single call.
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
public class LevelAssetLoader : MonoBehaviour
{
private AsyncOperationHandle<IList<GameObject>> _levelAssetsHandle;
public async void LoadLevelAssets(string levelLabel)
{
_levelAssetsHandle = Addressables.LoadAssetsAsync<GameObject>(
levelLabel,
prefab =>
{
// Called for EACH asset as it loads
Debug.Log($"Loaded: {prefab.name}");
});
await _levelAssetsHandle.Task;
if (_levelAssetsHandle.Status == AsyncOperationStatus.Succeeded)
{
Debug.Log($"All {_levelAssetsHandle.Result.Count} assets loaded for {levelLabel}");
}
}
public void UnloadLevelAssets()
{
if (_levelAssetsHandle.IsValid())
{
Addressables.Release(_levelAssetsHandle);
}
}
}using UnityEngine;
using UnityEngine.AddressableAssets;
public class TypedReferences : MonoBehaviour
{
// Generic reference — loads as UnityEngine.Object
[SerializeField] private AssetReference genericRef;
// Typed references — type-safe in Inspector
[SerializeField] private AssetReferenceGameObject prefabRef;
[SerializeField] private AssetReferenceTexture2D textureRef;
[SerializeField] private AssetReferenceSprite spriteRef;
[SerializeField] private AssetReferenceT<AudioClip> audioRef;
[SerializeField] private AssetReferenceT<ScriptableObject> dataRef;
// AsThe ultimate Claude Code toolkit for Unity game development. A production-ready, plug-and-play system that gives Claude Code deep Unity expertise — from writing performant C# to building scenes, profiling performance, and triggering iOS/Android builds — all
Assembly definition management — when to create asmdefs, reference rules, Editor/Runtime/Test separation, platform filters, compilation speed optimization.
Structured commit trailers — adds Constraint, Rejected, Scope-risk, and Not-tested metadata to commit messages. Captures architectural decisions and known gaps…
Ambiguity gating — detects vague feature requests and forces structured requirements gathering with scoring across scope, platform, performance, integration,…
Event system patterns — C# events, UnityEvent, SO event channels, static EventBus. When to use each, zero-allocation patterns, memory leak prevention.
Configures Claude Code's statusline to display Unity workflow state — current phase, active agent, files modified, and session duration.
Post-debugging knowledge extraction — captures non-obvious, codebase-specific learnings that pass quality gates. Invoke after resolving tricky bugs or…