Mesh 'type mismatch' in inspector for prefab

Just wondering why I’m getting ‘Type mismatch’ in the inspector for the Mesh field of a Mesh Filter on a prefab? See image below.

This is for my own procedural mesh (a sprite).

The preview is being drawn correctly so the mesh at this point must exist.

When the prefab is instantiated in a scene the Mesh field shows the little mesh icon.

Any comments?

File a bug. :slight_smile:

Make sure to attach the script.

Bug reported (same one as for http://forum.unity3d.com/threads/151453-Scene-object-not-refreshing-visually-after-prefab-%28and-object-itself%29-change?p=1052067#post1052067)

#492640

I guess this suddenly belongs in answers but I’ll include it here regardless.

Essentially that is because you’re referencing a mesh thats not an asset. Whenever you do new Mesh() you create a mesh in the scene. Its only if you give it to the asset database that it becomes an asset. Scene objects can be cleaned up by the editor at a number of times. This is handled just fine by the scene, but it doesn’t work properly with the prefab system. Leaving a stray pseudo released mesh on the prefab.

A check like this will tell you if its a good idea to create a nonserialized scene mesh in your script in the editor.

#if UNITY_EDITOR
if (!UnityEditor.EditorUtility.IsPersistent(this))
#endif

2 Likes

I’ve been looking for this answer in my dreams for a few weeks now. I was having the same problem, but with animation clips added to a prefab. This really needs to be added to documentation or something. Or if it’s there, it needs to be made more explicit. I was under the assumption that Unity handled its asset database automatically when you do a “new Anything()”

I have the same problem with Sprites created at runtime using images(textures) loaded from disk (or downloaded).
In inspector I can see “type mismatch” for sprites objects. This is only visual inspector bug i suppose, because when I click on select asset point I can see the current sprite preview correctly at the bottom of the select sprite window, there just no reference to the assed database (no asset exists in project view). Unity may fix this visual bug simply replacing “type mismatch” with something more appropriate, ex: “runtime asset”.

Hi there,
I have a 2D sprite animation, which I created in scene.

I want to control when it starts and stops. I thought I needed to do this via the Animator component, but it seems I need to do it via the Animation component.

Here in lyes my problem.

When I add a “public Animation anim” variable to my script, in the inspector, I get a “Type mismatch”, in the respective field.

So, all I need to know is how I can control an animation, to stop and start.

Help.

at least it happens if you changed your public variable type in the script… so just assign the reference again.

is your reference object using Animator or Animation?

1 Like

UPDATE:
I just re-entered the variable as you suggested and it appears normal!! Yeh.

---- original post.
Forgive me if my understanding is off…

I dragged a group of sprites into the scene, making the animation. This creates the Animator and Animation.

I see no reference to Stop() or Play() via the Animator, but I do via the Animation. However, Animation, posts the “Type mismatch”.

??

feku

I have the same problem. When I set an Object to ScriptableObject, getting type mismatch from Object. How to handle this issue ?