- Home /
Combined Mesh (root: scene) - How can I detect if a Mesh is a static combination?
This isn't as simple as it might sound - at least not to me!
If you make a call Resources.FindObjectsOfTypeAll(typeof(Mesh)) and you have any static batching going on, you will get back one or more meshes with the name Combined Mesh (root: scene). My understanding is that these meshes are the result of applying static batching to a scene (please shout loudly if you know differently!).
I'd like to identify this mesh as being the static combination of some other meshes, as I need to be able to treat it differently. I could consider all meshes with a name beginning Combined Mesh as static, but it does feel a bit hacky. The only thing I can see that might be useful, is that the underlying instance ID
some_mesh.m_UnityRuntimeReferenceData.instanceID
Is negative, but firstly, I don't know if that's going to persist either, or just a fluke of my setup and secondly I think I'd have to use reflection to get at this ID, although that's probably not too much of a problem.
Has anyone done this? Does anyone else have any suggestions?
Please read the question thoroughly - I am not after determining whether a gameObject is marked static.
Thanks Bovine
Ahh, if negative are Unity Engine runtime created items, then Object.GetInstanceID() makes it easy to see the instanceID I'm seeing here...
I see editor items such as cube, sphere, capsule etc... so these are Unity items, but presumably exist for rapidly drawing the built-in primitives?
Answer by whydoidoit · Aug 26, 2012 at 11:11 AM
Yes a negative GetInstanceID() does indicate that the object was created at run time. Positive IDs will be either scene or project objects (it's a bit of a shame that it is hard to distinguish between those two categories at runtime - though it can be done in the Editor).
And as we discovered, much to our irritation, this did not persist on iOS where many of my runtime objects had positive IDs that in the editor had been negative :-/
Aye, you may recall I had to resort to inspecting the name of the mesh, which is fragile to say the least! :o/