Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

AssetBundle to prefab => meshes/textures missing

$
0
0
Sinds Unity Pro 4.2 our AssetBundles no longer work when trying to load them in our Unity web project. The error message says something about rebuilding the AssetBundles. So that's what I'm trying to do. The problem is that the project started 3 years ago and we can't find the original assets that were used to build the AssetBundles. I've created an editor script that reads the AssetBundle (in Unity 4.1.5) and creates a prefab from this. Like so: ---------- void ExtractBundle(AssetBundle bundle) { var loadNames = new[] { "nav_a", "pick", "nav_z", "nav_y", "opslag" }; var parentName = Path.GetFileNameWithoutExtension(_pathBundle); var go = new GameObject(parentName); foreach (var loadName in loadNames.Where(bundle.Contains)) { var child = (GameObject)bundle.Load(loadName, typeof(GameObject)); child.name = loadName; child.transform.parent = go.transform; } CreatePrefab(go); //bundle.Unload(true); } private static void CreatePrefab(GameObject go) { PrefabUtility.CreatePrefab("Assets/Prefabs/" + go.name + ".prefab", go); } ---------- The problem I'm facing is that the prefabs are missing the meshes and textures/materials. **What am I doing wrong here?** As soon as I close Unity and reopen it again all meshes and textures are gone and Unity says mesh missing. The meshes I see before I restart Unity are clearly in memory (I can see it when instantiating the generated prefab). I've tested this further and discovered that when I write: bundle.Unload(true); in the code after the CreatePrefab(go); line. I never see the meshes so they have to be stored only in memory. Can someone please help because, although the AssetBundles are not complex, there are almost 200 of them!

Viewing all articles
Browse latest Browse all 171066

Trending Articles



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