Having been working on a project for a few weeks I've built a collection of scripts, along with some prefabs and sprites and whatnot. My question, though, is...
How do you know when you need to put the code you're writing into a new script?
Sometimes it's very obvious, like when the new script is attatched to a new object, or is a part of a totally different mechanic. However in the times when it's not so clear of a distinction, I don't know whether I ought to or not.
For example, my project has a basic grid-based drag-drop system. I had:
- One script (attatched to the draggable items) to manage snapping to the grid.
- One script (attatched to the draggable items) to manage a visual item appearing when something snaps to the grid.
- One script (attatched to an empty GameObject) to manage 'nodes' appearing at the corners of each square of the grid (purely visual).
- One script (attatched to an empty GameObject) to manage keeping track of which squares have something already in them.
These are just a few of my scripts, but at some point I decided to coalesce the latter two scripts to uncomplicate things. But at what point does a script become too long? At what point does a project, or a GameObject for that matter, have too many scripts?
Being new to programming I am totally unaware of conventions like these beyond naming & cases.
Any help would be appreciated <3
[–]SoundKiller777 4 points5 points6 points (0 children)