Quantcast
Channel: Questions in topic: "assetbundles"
Viewing all articles
Browse latest Browse all 312

AssetBundle Textures not loading

$
0
0
Found a project https://unitylist.com/p/3vq/Card-Example-Unity and wanted to make it work on Android. Stumped by the Texture not loading The code line is: GetComponent().material.mainTexture = cardBundle.LoadAsset(TexturePath); https://github.com/CrandellWS/Unity-Card-Basics/blob/acf532644d0f437273e45960d154605e5a59adf0/Assets/CardFramework/Scripts/Component/Card.cs#L89 public AssetBundle LoadBundle(string path) { string name = System.IO.Path.GetFileNameWithoutExtension(path); AssetBundle assetBundle = GetBundle(name); if (assetBundle == null) { assetBundle = new AssetBundle(); //assetBundle = AssetBundle.LoadFromFile(path); assetBundle = AssetBundle.LoadFromFile(System.IO.Path.Combine(Application.streamingAssetsPath, path)); assetBundle.name = name; AssetBundleList.Add(assetBundle); return assetBundle; } else { return assetBundle; } } https://github.com/CrandellWS/Unity-Card-Basics/blob/acf532644d0f437273e45960d154605e5a59adf0/Assets/CardFramework/Scripts/Singleton/BundleSingleton.cs#L35 The path is set as a variable `card.TexturePath` public void InstanatiateDeck(string cardBundlePath) { AssetBundle cardBundle = BundleSingleton.Instance.LoadBundle(cardBundlePath); string[] nameArray = cardBundle.GetAllAssetNames(); for (int i = 0; i < nameArray.Length; ++i) { GameObject cardInstance = (GameObject)Instantiate(_cardPrefab); Card card = cardInstance.GetComponent(); card.gameObject.name = Path.GetFileNameWithoutExtension(nameArray[ i ]); card.TexturePath = nameArray[ i ]; card.SourceAssetBundlePath = cardBundlePath; card.transform.position = new Vector3(0, 10, 0); card.FaceValue = StringToFaceValue(card.gameObject.name); CardList.Add(card); } } View and download this project on GitHub https://github.com/CrandellWS/Unity-Card-Basics/ Any help is appreciated Thanks.

Viewing all articles
Browse latest Browse all 312

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>