Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
372 views
in Technique[技术] by (71.8m points)

c# - Is it possible to check if the AssetBundle is already in cache?

I have succeeded in loading the asset bundle using UnityWebRequestAssetBundle.GetAssetBundle(). If it's already in the cache, it loads from local, if not, downloads it from the web.

I don't want to start downloading immediately when AssetBundles are not cached locally. I want the user to decide whether to download it now or not. How do I pause when I need to download, and decide whether to proceed with the download now or not?

This is the current code.

IEnumerator DownloadAndCache()
{

    string hash = "c1d228abfafede3d05affe6bd2e3b209";
    Hash128 hash128 = Hash128.Parse(hash);

    UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(uri, hash128, 3300783334);
    
    yield return request.SendWebRequest();

    GameObject cube = bundle.LoadAsset<GameObject>("Assets/Art/Event_test/EventMain3.prefab");
    GameObject sprite = bundle.LoadAsset<GameObject>("Assets/Art/Event_test/EventMain2.prefab");

    Instantiate(cube);
    Instantiate(sprite);

}
question from:https://stackoverflow.com/questions/65909060/is-it-possible-to-check-if-the-assetbundle-is-already-in-cache

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...