When you have a important gameobject, such as the player, does a large number of components affect the performances ? I’m talking about around 10 - 15 here.
I try to have very specific scripts for clarity and reusability, so right now I have MeshFilter - Collider - Renderer - Char Contr. - Char Motor - A generic class for interactions - Inputs - Seeker (path finding) - Inventory - All sorts of GUI - etc.
All that on a single GameObject. Is it a bad idea ? Would it be better to dispatch them on children ? What if there is even more ?
PS : This is for webplayer / standalone.
It really all depends. The things that are going to affect performance the most in this type of situation are the monobehavior functions that get called every frame (Update) or even multiple times a frame (OnGUI). So if every single one of your components inherit from monobehavior and each have their own Update, OnGUI, ect, functions yes this is going to affect performance some. And even then breaking them out to child objects is not really going to help because you will still have the same number of calls to update ect every frame.
So how do you combat this? Generally with a mixture of, creating a careful inheritance structure to your classes and if needed a little bit of state based programming.
For your all sorts of components for GUI stuff you could use a more state based approach. Say each component implements a different menu screen or something. Instead of letting each one have their own OnGUI function and constantly checking whether or not they should be drawing somewhere inside of that OnGUI function you could instead take all that code you would put in OnGUI and rename it to a function like Draw. Then you could call a particular menu components draw function from inside of the OnGUI function of your PlayerController based on what menu state the player was in.
So this is a pretty long answer, but like I said in the beginning it really all depends on what you are doing. If you have have an object with 15 or so components but really only one 2 or 3 are controllers with updates being constantly called and the rest are just some sort of gui stuff that is just siting there waiting to be run in an OnGUI call, you are probably fine. If you have 15 components all with their own updates doing their own things you may want to rethink you design a bit. But then again if there are not very many complex things going on in your scene it could be just fine too. It really all depends on the project and situation.
I think this is the answer you are looking for buddy: