0

Every GameObject has Transform, and only one. Every Transform can only be created attached to a GameObject. Hierarchy is realized through Transform, but GameObject relies heavily on it.

Is there a reason about why they are different entities and not the same thing?

Max Yankov
  • 12,551
  • 12
  • 67
  • 135

1 Answers1

0

Component's and GameObject's are inherited types of a base class called Object. Component's can only exist and be attached to Objects.

A Transform is an inherited type of Component. All GameObject's must have a Transform Component attached to them. The reason being:

Every object in a scene has a Transform. It's used to store and manipulate the position, rotation and scale of the object. Every Transform can have a parent, which allows you to apply position, rotation and scale hierarchically. This is the hierarchy seen in the Hierarchy pane.

If you asking why such an architecture is in place, you may find that this sort of discussion will be found debated in more than a few articles and books. I once asked this question myself and I found the following Stack Overflow answer to best answer it HERE.

Community
  • 1
  • 1
S.Richmond
  • 11,412
  • 6
  • 39
  • 57
  • Your answer explains how things are. But that wasn't my question. I was interested _why_ they are this way. Why did Unity engineers design it to be so? – Max Yankov Nov 08 '13 at 07:56
  • Edited my answer to provide you a link to another StackOverflow QnA that I think will provide you your answer. – S.Richmond Nov 08 '13 at 08:27
  • I'm familiar with component-based design, and I used decorator-like behaviors in projects before Unity; however, in this design pattern it still doesn't make sense to make the behavior which is always present on an object a separate decorator. – Max Yankov Nov 08 '13 at 10:01
  • I have edited the answer to include a relevant link that may better answer your question. – S.Richmond Nov 11 '13 at 04:06