Compile-driven bulk-copy loop (tools/engine-port/m1_copy_loop.py) pulled the precise reference closure of the battle-core roots, stopping at the classify god-object/View-VFX-UI boundary. 782 files; no re-explosion (M0 had estimated ~order 1000). Residual frontier = 52 shim-classified + 80 external (Unity/BCL) types to author next.
54 lines
1.0 KiB
C#
54 lines
1.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Cute;
|
|
using UnityEngine;
|
|
|
|
public class ResourceHandler : MonoBehaviour
|
|
{
|
|
private Dictionary<string, List<Action>> _onLoad;
|
|
|
|
private HashSet<string> _loaded;
|
|
|
|
public ResourceHandler()
|
|
{
|
|
_loaded = new HashSet<string>();
|
|
_onLoad = new Dictionary<string, List<Action>>();
|
|
}
|
|
|
|
public void Add(string path, Action action)
|
|
{
|
|
if (_loaded.Contains(path))
|
|
{
|
|
action();
|
|
return;
|
|
}
|
|
if (_onLoad.ContainsKey(path))
|
|
{
|
|
_onLoad[path].Add(action);
|
|
return;
|
|
}
|
|
_onLoad[path] = new List<Action>();
|
|
_onLoad[path].Add(action);
|
|
StartCoroutine(Toolbox.ResourcesManager.LoadAssetAsync(path, delegate
|
|
{
|
|
for (int i = 0; i < _onLoad[path].Count; i++)
|
|
{
|
|
_onLoad[path][i]();
|
|
}
|
|
_onLoad.Remove(path);
|
|
_loaded.Add(path);
|
|
}));
|
|
}
|
|
|
|
public void UnloadAll()
|
|
{
|
|
Toolbox.ResourcesManager.RemoveAssetGroup(new List<string>(_loaded));
|
|
_loaded.Clear();
|
|
}
|
|
|
|
public void OnDestroy()
|
|
{
|
|
UnloadAll();
|
|
}
|
|
}
|