As relatively new to Unity C#, i followed the guidance of this post: Build and load Assetbundles in Unity
I was able to successfully build the assetBundles into the StreamingMedia folder. But using this posts guidance on the second half of loading
The script will not compile with the error below. I am sure it is my relatively new skills in Unity, but i am wondering what i am missing. Once i can successfully recreate this, the eventual intent is to use it to load GameObject from the assetBundles.
Any guidance is most appreciated.
ERROR Referencing the "yield return asset;" line.
Error Assets/Scripts/loadBundleAsset.cs(22,23): error CS1519: Invalid token ';' in class, struct, or interface member declaration
appreciatively
Have attempted to follow the guidance of the previous post. Build and load Assetbundles in Unity Also have been doing reading about the use of EInumerators and Coroutine in Unity
Here is basis of the script as i interpreted that post.
IEnumerator LoadAsset(string assetBundleName, string objectNameToLoad)
{
string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, "AssetBundles");
filePath = System.IO.Path.Combine(filePath, assetBundleName);
//Load "animals" AssetBundle
var assetBundleCreateRequest = AssetBundle.LoadFromFileAsync(filePath);
yield return assetBundleCreateRequest;
AssetBundle asseBundle = assetBundleCreateRequest.assetBundle;
//Load the "dog" Asset (Use Texture2D since it's a Texture. Use GameObject if prefab)
AssetBundleRequest asset = asseBundle.LoadAssetAsync<Texture2D>(objectNameToLoad);
yield return asset;
//Retrieve the object (Use Texture2D since it's a Texture. Use GameObject if prefab)
Texture2D loadedAsset = asset.asset as Texture2D;
//Do something with the loaded loadedAsset object (Load to RawImage for example)
image.texture = loadedAsset;
}
Script will not compile, indicating the following error. When placed in a full script i expected to compile.
Error Assets/Scripts/loadBundleAsset.cs(22,23): error CS1519: Invalid token ';' in class, struct, or interface member declaration