Unity3d :: UML :: Transform visualization cheat sheet
Hi,
Here is a detailed UML class diagram of the Transform API for Unity 3D.
Coming from an ActionScript – Flash background, this class stumped me for a bit until I really started looking into the api docs and realizing that GameObject is just a container for composite instances such as the Transform class. The Transform instance is accessed through the GameObject.transform instance property as well as a couple other ways with methods like GameObject.GetComponent().
In ActionScript, the UIComponent owns, measures, lays out and renders the display object children (although UIComponent is abstract for measurement and layout). In a sense, the UIComponent is the Transform as well as a million other things. Have you seen how many lines of code UIComponent has in Flex 4?
What Unity3D does is composite all the features such as transform into the class. Adobe should take note, this is a much cleaner design since having the composite instances create any easy interface for each section the GameObject contains. There are clear boundaries between functionality.
As we can see in the UML, the Transform class deals with it’s own position, scale and rotation and also has the duty of containing other Transform children. In the whole design pattern area this is called the composite pattern. The composite is a tree of instances that share the same api (interface).
Basically the action duties of the Transform class include;
- Addition and removal of children
- Child queries
- Translation (position) transform
- Rotational (rotation) transform
The Transform class makes heavy use of the following;
Vector3(position)Quaternion(rotation)Matrix4x4(transform)
The parent
In a lot of graphical languages you will have a method called addChild() or addElement(). In Unity3D, there is no method for adding a child to a Transform. Setting the parent property of the parent Transform will automatically add the child Transform to the parent.
The root
The root property returns the top level Transform that is attached to the Scene. This could also be achieved by creating a while() loop and looping through the Transform.parent until null is reached.




Recent Comments