Hey All!
Basically I need help with getting a path from an asset that has been taken out of an asset bundle.
Firstly I’m not even sure if you can. But at the moment I want to take the asset from the asset bundle and put it in the persisantData path.
What I got below returns an empty string which means I cant tell SaveAndDownload where to look.
I’m really stuck on this. Maybe there might be another way to do it?
public AnimatedGifPlayer animatedGifPlayer;
public string url;
public Texture2D testTexture;
[ContextMenu("Starter")]
public void Starter()
{
testTexture = [Asset Bundle With Object].LoadAsset<Texture2D>("grass.gif");
// This returns an empty string
string assetPath = AssetDatabase.GetAssetPath(testTexture);
url = assetPath;
StartCoroutine(SaveAndDownload(Application.persistentDataPath + "/grass.gif"));
}
IEnumerator SaveAndDownload( string saveTo)
{
WWW www = new WWW(url);
yield return www;
byte[] bytes = www.bytes;
File.WriteAllBytes(saveTo, bytes);
Debug.Log(url);
yield return new WaitForSeconds(1);
Debug.Log("Load");
//Do something with the new file
}
}