Quantcast
Channel: Questions in topic: "assetbundle"
Viewing all articles
Browse latest Browse all 1593

How to load a mesh from an asset bundle?

$
0
0
I'm trying to load a mesh with scripts to replace another mesh. I'm not doing a Unity project but rather a visual studio project with unity references. My code for loading the asset bundle and getting the mesh is: // var vshojoBundle = AssetBundle.LoadFromFile("vshojo"); if (vshojoBundle == null) meshNames.Add("bundle nor read"); GameObject silverObject = vshojoBundle.LoadAsset("SilverAssets.obj"); MeshFilter silverNewMesh = silverObject.GetComponent(); meshNames.Add(silverNewMesh.mesh.name); // MeshNames is a list that later gets written in a log file to help me figure out things. When trying to get the name of the mesh in the last line, I get the following error: "NullReferenceExpection: System.NullReferenceException: Object reference not set to an instance of an Object". The same exception occurs if I don't use that line to write on log and skip to the mesh replacement, when I replace the mesh I get the same error.

Viewing all articles
Browse latest Browse all 1593

Latest Images

Trending Articles



Latest Images

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