x


Mesh Disappears simply by mentioning it in a script

Quickest way to produce the problem in c#:

using UnityEngine;
using System.Collections;

public class asdf : MonoBehaviour
{
    public GameObject thing;
    void Start()
    {
       Debug.Log (thing.GetComponent<MeshFilter>().mesh); //Look at your debug window in unity
    }
}

REMEMBER to name it asdf.cs AND to assign the script a model AND to place the script on a model.

The problem: play the game. Now quit it. The mesh disappears from mesh filter.

REMEMBER to reimport the model to test again.

Important Details: Hit play after reimporting, and click on your model inside the project panel. In the inspector, scroll down where you see the tab "Imported Object" and look at the mesh filter, the mesh has became "Type misMatch".

I tried my best make this as detailed yet short as possible, if you request that I get more information please tell me. (and how, if needed , since I'm a beginner)

EDIT: I am using Mac OSX 10.6.8 and I am using Unity version 3.5.2f2.

more ▼

asked Jun 25 '12 at 07:37 PM

Ribboninju gravatar image

Ribboninju
0 1 1 2

Sounds like should be a bug report. I assume you have tried MeshFilter meshFilter = thing.GetComponent<MeshFilter>(); Debug.Log(meshFilter.mesh); which may give different results. Not really sure what mesh 'to string' will do.....

Jun 25 '12 at 08:11 PM DaveA

I will look into it more later, but I found that one could cheaply hack by adding the mesh as a public variable, and assigning it to the model. thing.GetComponent().mesh = publicmesh;

What a very weird problem, I might have to bug report it if the things you said gave the same result.

The fact that the compiler doesn't complain about the "Type misMatch" scares me.

EDIT: gosh, just merely mentioning the string makes it lose the mesh. Looks like I might have to report a bug.

Jun 25 '12 at 08:29 PM Ribboninju

1) What type mismatch? 2) I followed your steps and the mesh does not disappear.

Jun 25 '12 at 08:54 PM Eric5h5

Could be an issue special to my computer. I am using Mac OSX 10.6.8, But if there's anything more I could say let me know.

If it produced the bug, where it would say the name of the mesh with a circle on the right (like cube or plane), it would turn into "Type misMatch"

Jun 25 '12 at 08:56 PM Ribboninju
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

I got this same problem. Couldn't figure out the why, but found a different work around. If you are not going to be modifying the mesh you can use something like.

MeshFilter mapMesh = gameObject.GetComponent<MeshFilter>();
Debug.Log(mapMesh.sharedMesh);

With the sharedMesh you are calling the actual Mesh(mother) and not the instantiated shape(daughter).

Just remember that if you modify this sharedMesh all of the objects that use it will be modified as well. Check the documentation for more info :)

more ▼

answered Aug 10 '12 at 08:42 PM

SantiMuffin gravatar image

SantiMuffin
1 2

(comments are locked)
10|3000 characters needed characters left

SOLUTION: create a public Mesh of that model and assign it to the model.

SCRIPT:

using UnityEngine;
using System.Collections;

public class asdf : MonoBehaviour
{
    public GameObject thing;
    public Mesh thingy;
    void Start()
    {
       Debug.Log (thing);
       Debug.Log (thingy);

       thing.GetComponent<MeshFilter>().mesh = thingy;
    }
}

Now you can never lose the mesh, however this is more of a workaround of a bug that should be reported than a solution.

more ▼

answered Jun 25 '12 at 09:08 PM

Ribboninju gravatar image

Ribboninju
0 1 1 2

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1366
x108
x64
x6

asked: Jun 25 '12 at 07:37 PM

Seen: 646 times

Last Updated: Aug 10 '12 at 08:42 PM