- Home /
Is this accurate? Scenes are composed of objects are composed of components are composed of assets
A few days ago, someone told me that in general:
Scenes are composed of objects, objects are composed of components, and components are composed of assets.
Is this a good general rule of thumb when first teaching someone about Unity3D? Are there any major exceptions to this model that make it misleading for people just starting out in Unity (IE not advanced people)?
Thank you for the second opinion!
Answer by Paricus · May 26, 2017 at 07:27 PM
not sure about the assets part, they're usually used to be brought in as objects/components. It's better not to think of objects as a collection of components (which they basically are), but rather as items in your scene which can have behaviours attached to them (e.g. attaching a rigidbody component makes the item/object act realistically with physics).
This entire set up however will become intuitive with use of the engine, so just mess around with it and you'll be fine.
I don't quite understand your statement that he shouldn't see objects as a collection of components but as a collection of behaviours. Behaviours are just a specific kind of components. However objects doesn't only consist of behaviours but also other components which do not represent any behaviour.
A renderer for example is a component which gives the object a visual representation of some sort. However that is not a behaviour but simply a "feature" or "state" of that object. The same is true for colliders or the transform component. They just hold data in a passive manner. Just have a look at the class hierarchy.
Behaviours are components which influence / define / extend the behaviour of the object. $$anonymous$$onoBehaviours are simply behaviours which are created with the $$anonymous$$ono framework (hence the name). Behaviours change the state of the object or react to state changes of other objects. The rigidbody component defines state (like velocity, angularVelocity, mass, ...) as well as a behaviour.
Your own scripts ($$anonymous$$onoBehaviours) can also define both, state and behaviour. A better class name would have been "$$anonymous$$onoComponent" though that's rather irrelevant.
I would say the definition given in the question is actually on point.
Scenes are composed of GameObjects.
GameObjects are composted of Components
Components might reference assets (textures, meshes, audioclips, materials, ...)
GameObjects in the scene can have a prefab reference that link the instance in the scene with a prefab asset. Though this is currently just an editor feature