本文主要是介绍SpriteAtlas的加载(非Include in Build),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
下面的代码是非Include in Build模式
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.U2D;public class loadpre : MonoBehaviour {public string prefabBundle = "preab_late";public string saBundle = "atlasab_late";IEnumerator Start (){var loadOp = new WWW("file://" + Application.streamingAssetsPath + "/" + prefabBundle);yield return loadOp;var prepre = loadOp.assetBundle.LoadAsset<GameObject>("prop_parachute");GameObject.Instantiate(prepre);}void OnEnable(){SpriteAtlasManager.atlasRequested += RequestLateBindingAtlas;}void OnDisable(){SpriteAtlasManager.atlasRequested -= RequestLateBindingAtlas;}void RequestLateBindingAtlas(string tag, System.Action<SpriteAtlas> action){StartCoroutine(LoadFromAssetBundle(tag, action));}IEnumerator LoadFromAssetBundle(string tag, System.Action<SpriteAtlas> action){var loadOp = new WWW("file://" + Application.streamingAssetsPath + "/" + saBundle);yield return loadOp;var sa = loadOp.assetBundle.LoadAsset<SpriteAtlas>(tag);action(sa);}}
这篇关于SpriteAtlas的加载(非Include in Build)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!