What is the difference between Transform and Recttransform

After using Unity for a while I see that some game object use transform while other use recttransform. So I would like to know:

  • What is the difference between Transform and Recttransform?
  • Which situation you should use Transform instead of Recttransform or the opposite?

Transform is a component for defining a GameObject’s relative position, rotation, and scale. The parent, and zero or more child objects are also described here. Most objects added to a scene get this assigned automatically.

RectTransform is a Transform, but with extra info for managing an object as a UI element. So, some aspects might be constrained (greyed out) by parent objects. This includes information for managing a relative pivot and anchor, for example. You can also use the T mode in the Unity scene view to adjust things with a RectTransform, which can make it nice to edit UI edges and anchors.

Objects added to the scene through the Unity menu creating a UI object will have RectTransform automatically, as will any empty objects added as children to that object.

The docs have a lot more details on this.

RectTransform is inherited from Transform and is normally used with GUI, but You can use it for other things. It has all of the inherited properties of Transform, but it also contains anchoring properties which are great for the GUI.