i´ve added an additional third light to my scene and want to mask a platform on which stands other objects, so the light will not affect the platform. I added a new layer called “platform” and assigned it to the object with all its children (on which i assigned the “combine children” script). Then i chose this layer in the culling mask proberty.
If i´m playing the scene and switching the mask on/off, it doesn´t work correct and the platform is anyway affected by the light.
If I´m turning of the “combine children” script on this platform, it works well.
So the problem has to be because of the platform, but i don´t have a clue.
Does someone have further ideas how to deal with, please?
If you have more than one material in the child objects, then CombineChildren will create a new child GameObject called “Combined Mesh” for each material (line 74 of CombineChildren.cs). However, these created GameObjects are not assigned to any particular layer. You could find the created child objects and set the layer in the Start method, or else modify the CombineChildren.cs script so that the correct layer is assigned to the new child objects as they are created.
Also, Mesh.CombineMeshes is an alternative that may work better for you here.
Thanks andeee for your fast reply. Nice to get help…
Can you please explain where are the differences between combine children and Mesh.CombineMeshes?
After reading it twice, its not clear to me.
Would be great, thanks.
…and… how can i find the right one in the generated combined Mesh layers?
Mesh.CombineMeshes is just an alternative to the Combine Children script that may be easier to use, depending on what you want to do. If Combine Children is working out well, there’s no particular reason to change it.
The reason that the light culling doesn’t work after combining the meshes is that the culling mask is activated by the layer that the object is on. When Combine Children encounters a mesh with different materials, it creates a separate child object for each mesh. However, the script doesn’t set the new objects’ layers to anything in particular (bear in mind that if you are combining several objects, they may all be on different layers, so it is not obvious which should be used.) You could modify the processing loop of the Combine Children script so that it sets the layer of each child to a chosen value. Among the lines that set the GameObjects’ properties (around line 74) you need to add a line like:-
go.layer = <whatever layer number the culling depends on>;
It might also be useful to add a public variable to set the layer from the inspector.