How do I ensure Combined Children Meshes are on the layer I want?

I'm making a simple fps. So I downloaded this pistol mesh I found. This pistol is made up of many (92) smaller meshes, and predictably draw count was too high. So I put the combine children script on the pistol mesh's parent object. Worked like a charm.

I also placed the pistol (parent and children) in a separate layer so that a secondary camera can draw the pistol over everything else.

However, whenever I play test the game the newly created combined children meshes are on the default layer, thus losing the desired effect.

So my question is basically : How can I make the children meshes to be on any layer I choose? How can I make sure that they will be made in the correct layer? I am expecting the solution to be in the form of some script, or editing the combine children script, but I don't know how to go about this. Help please!

This may be slightly sidestepping the question, but is there a particular purpose that the pistol be made up of 92 (?!) tiny meshes?

It sounds like it'll be a nightmare just having all those Game Objects floating around when it's not necessary, I'm thinking just for cleanliness and workflow's sake.

Firstly I'd try finding a better-made model before you decide you want to fiddle with a broken apart one that isn't broken apart for any good reason. If you need a better place to find models, there's always TurboSquid, just search and filter for free stuff. I'm sure there are quite a few good free ones to get (I've casually sold my models there for a while so I know there's a wide selection).

If you don't want to use a different one, I'm not sure how to fix the original problem at hand as I haven't got much experience using combined meshes and layers.

Okay so after sleeping on it and doing a little research, I've come up with two solutions.

The first solution is to swap everything layer-wise. Have the gun on the default layer, which my camera draws on top of the second layer where every other game object will be.

This isn’t the best way to handle it and has a couple of downsides.

The best way is to modify the combined children script.

There wouldn't have been an issue if all the meshes had the same material, since the script makes the parent object take upon itself the combined mesh of all its children. So if I wanted to make sure the combined mesh went on a certain layer, I would simply have to change the parent's layer in the editor.

But since they have more than one material, the script has to make objects in order for them to take the meshes. And you can't adjust these objects that aren't even created yet in the editor, you'll have to edit them in the script.

So where you find this in the script :

        else
        {
            GameObject go = new GameObject("Combined mesh");
            ...

Add this somewhere in the else statement (but not the top) :

        go.gameObject.layer = layerid;

Layerid is the number of the layer you want to place the gameobjects in.

So yeah, all it took was a simple addition to the script! xD