Every time I close Unity 3 basic and reopen it my prefabs are missing their meshes.
When I drop a prefab into the scene it’s seemingly invisible, except everything is in order in the hierarchy, if I select the mesh in the hierarchy the Skinned Mesh Render component reads Missing (Mesh) by the Mesh variable.
Should I be storing the meshes in a separate folder somewhere? I assumed the prefabs stores everything they needed within themselves.
I’m referencing the prefabs in two scripts, both of which are using the Destroy() function, but I’m destroying the instances, not the references, as far as I can see.
Could someone take a look over my two scripts and tell me if I’ve done something wrong here? I can’t bare to set the rigs up again only to have it vanish when I close Unity.
You might get more people to check out your scripts if you just post them here (just be sure to use ‘code’ tags and to make sure the code is formatted correctly).
*Edit Seems my scripts are too long to paste into the post or replies, I used pastebin because it highlights the syntax correctly and makes it easier to read
Pastebin = interesting, however, this issue you are describing doesn’t have anything to do with the code, although the code is spaghetti, should work, as long as your prefabs have the meshes and textures assigned to them, the rest doesn’t matter. It doesn’t matter if you do anything in code to the game objects, it won’t alter the core prefab directly. Or it shouldn’t anyway, either way FYI code is fine.
Ok well I opened Unity, created a new prefab, created a cube, added the cube to the prefab, deleted the cube from the hierarchy, closed and reopened Unity and the prefab was fine, still had its cube mesh.
My workflow so far has been to model a bird, with a head and body, the body’s rigged and skinned, the head is not. I import them as an fbx, set them up in the rig, and delete the original fbx, once the mesh’s rig is finished and it has the scripts required for when I instance it, I make a new prefab, drop the rigged mesh into it and delete the original. The game runs fine, instances the prefabs with the meshes fine, until I close and reopen it, then the meshes have disappeared from the prefabs. Once I get these two main body parts working correctly I’ll add the rest.
My goal is to create characters that require little to no animation for the movement, and apart from this problem it’s working pretty well.
I realize my code is not great, but I’ve never had any formal teaching, and I’m a 3d artist, not a programmer, so if you could give me advice/tips, rather than just calling it spaghetti, I’d appreciate it I’ve a feeling the code is executing far more times than it needs to, because I’m using OnGui, once I resolve this problem Ima go learn what yield does, and if I can use it
Well, it’s a lot of work for me to import the original fbx and rig them again, so I’ll leave that as plan C hehe
I went back to Maya, exported just the missing meshes in an fbx with the same filenames, I cleared their history destroying the skin for the rig tho, imported them to Unity, dropped one of the malfunctioning prefabs into the scene, selected the torso with the missing mesh, and dragged and dropped the coresponding mesh file, from the fbx with the correct scale factor onto the mesh slot in the torso’s mesh variable of it’s skinned mesh renderer component and my screen starting flickering and the computer spazzed out so I had to force quit. I’m guess I pissed off the gpu or something. I’m running a year old macbook pro with two Geforce 9400m.
Seems this game is getting a bit messy…
The problem seems to be the mesh files for the prefabs are missing anyway, the prefabs either haven’t stored them or I’ve inadvertently deleted them.
I don’t think prefabs actually store anything; they’re more of a set of links to files in your project folder and info about how instances of those files were placed in the scene when it was turned into a prefab.
Trying to just replace components of a game object that results from importing an FBX file is likely to be problematic. I think you should re-import the entire original FBX files again, and leave them intact in the project folder this time.
The prefab gets its data from the FBX. That’s a GOOD THING. Here’s why.
Let’s say I model a bird, and I rig it, and create a walk cycle. I export the whole thing as an FBX.
In Unity, I then create a prefab, add a tophat and a grenade launcher to the bird, add scripts, rigidbody, etc.
If I then wanted to change the walk cycle, say to make the walk more stealthy, I could change that in my 3D app, export the FBX, and overwrite the old one in my Unity folder.
Now, if I play the game, the new walk cycle is automatically ‘in there’. No extra effort on my part.
So getting rid of the FBX is probably the problem here.
Yeah, absolutely don’t delete your fbx’s - doing so rids the mesh that your prefab assigns. Just like if you have scripts applied to your prefab and then deleted the scripts folder - the prefab would malfunction because it doesn’t duplicate the script into the prefab.
Yeah I guess I just missunderstod the purpose of a prefab, and you’re right Chilton that is quite useful. I’ll just bite the bullet and reimport the whole lot again and set it up again, and keep all the fbx files intact.
Thanks all for your help you’ve been great! :]