Skip to content

Instantly share code, notes, and snippets.

@tsubaki tsubaki/Rebind.cs
Created Dec 14, 2018

Embed
What would you like to do?
SpriteAtlasのリクエスト
using System;
using UnityEngine;
using UnityEngine.U2D;
public class Rebind : MonoBehaviour
{
Action<SpriteAtlas> atlasAction;
AssetBundle assetbundle;
const string assetBundleName = "atlas";
private void Awake()
{
assetbundle = AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/" + assetBundleName);
}
private void OnDestroy()
{
assetbundle.Unload(true);
}
private void OnEnable()
{
SpriteAtlasManager.atlasRequested += AtlasRequested;
}
private void OnDisable()
{
SpriteAtlasManager.atlasRequested -= AtlasRequested;
}
void AtlasRequested(string tag, Action<SpriteAtlas> atlasAction)
{
var request = assetbundle.LoadAssetAsync<SpriteAtlas>(tag);
request.completed += (op) =>
{
atlasAction.Invoke((SpriteAtlas)request.asset);
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.