Important Question About Scripts
Hey, Im a beginner game developer, Ive started to work on my own game, My game will contain al lot of scripts (more than 200) that need to communicate with each other
My Question is, Is it Okay to attached all my script on one game object ? and do my game lose preformance because of it ?
Thanks in advance :)
Could you explain? Why do you need more than 200 scripts on one gameobject? What are they doing? What are you trying to achieve?
I'm building a country management game, Every Country sector and each facility have different scripts, Every script need to check a lot of data that contain in other scripts. When I using get component<> method and it will work only on scripts attached to same game object. If the scripts not on the same game object i cant call any function or data that exist on other script.
I cannot really imagine a scenario where you need that many different scripts on one gameobject, but I certainly don't know your project, so it's really up to you. We could help you only if we got to know your project better.
Other than that, I think that it's really a trial and error thing. In terms of performance it depends on the frequency and complexity of the methods you call (which, again, cannot be predicted by us). Make sure to monitor your scripts.
Without any example, I can tell you only these.
When I using get component method and it will work only on scripts attached to same game object
FYI You can easily retrieve components attached to other gameObjects
Script script = otherGameObject.GetComponent<Script>();
Where otherGameObject
is a reference to another game object you get using the inspector / Find method / ...
Your answer
Follow this Question
Related Questions
Use placeholder text in CustomEditor 0 Answers
Wheel rotation 1 Answer
Calling from another C# Script is casuing Unity 5.4 to crash in editor mode. 0 Answers
How to change if you can click a button? 0 Answers
How to Make Pickups on a 3D plane? 0 Answers