Code architecture and attaching scripts

Is it ALWAYS better to attach your scripts to actual Game Objects? Coming from a Flash background, this feels like the old AS2 days, when you had to attach code physically to actual movie clips and in most OOP development is frowned upon.

A more general discussion of code architecture belongs on Unity Forums, but for the specific point at the core of your question: if a class is derived from MonoBehaviour, then it must be attached to a game object. For most development projects, there are good reasons to create classes that are not derived from MonoBehaviour. These classes can be handled in a traditional way. They are created by ‘new’, use a traditional constructor, and don’t require a game object to exist.


Unless you need one of Unity’s hooks you should not inherit from MonoBehaviour or attach your script to a GameObject.