This commit is contained in:
2025-09-17 18:56:28 +08:00
commit 54c72710a5
5244 changed files with 5717609 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.U2D;
using YooAsset;
public class SpriteAtlasLoader : MonoBehaviour
{
private Dictionary<string, SpriteAtlas> _loadedAtlas = new Dictionary<string, SpriteAtlas>(1000);
private List<AssetHandle> _loadHandles = new List<AssetHandle>(1000);
public void Awake()
{
SpriteAtlasManager.atlasRequested += RequestAtlas;
}
public void OnDestroy()
{
foreach (var handle in _loadHandles)
{
handle.Release();
}
}
private void RequestAtlas(string atlasName, Action<SpriteAtlas> callback)
{
if (_loadedAtlas.TryGetValue(atlasName, out var value))
{
callback.Invoke(value);
}
else
{
var package = YooAssets.GetPackage("DefaultPackage");
var loadHandle = package.LoadAssetSync<SpriteAtlas>(atlasName);
if (loadHandle.Status != EOperationStatus.Succeed)
{
Debug.LogWarning($"Failed to load sprite atlas : {atlasName} ! {loadHandle.LastError}");
return;
}
_loadHandles.Add(loadHandle);
callback.Invoke(loadHandle.AssetObject as SpriteAtlas);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a506251ccc863fe4182436d24685c181
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: