Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


transform

Returns a transform styles object for this VisualElement.
Read time 1 minuteLast updated 4 days ago

Definition

Warning
Deprecated. When writing the value, use VisualElement.style.translate, VisualElement.style.rotate or VisualElement.style.scale instead. When reading the value, use VisualElement.resolvedStyle.translate, scale and rotate
public ITransform transform { get; }

Remarks

The transform styles object contains the position, rotation, scale style properties of this VisualElement. Note: This transform object is different and separate from the GameObject Transform MonoBehaviour. The three interface members write to the visual element's inline style and read from the resolved style. However, the VisualElement.style API offers more features and is the recommended approach. For example, you can set translate and position as percentages through the VisualElement.style API.
The following example reads the current position, rotation, and scale from the resolvedStyle of a VisualElement, then updates the style properties with these values.

Examples

var visualElement = new VisualElement();Vector3 position = visualElement.resolvedStyle.translate;visualElement.style.translate = new Translate(position.x, position.y, position.z);Quaternion rotation = visualElement.resolvedStyle.rotate.ToQuaternion();visualElement.style.rotate = new Rotate(rotation);Vector3 scale = visualElement.resolvedStyle.scale.value;visualElement.style.scale = new Scale((Vector2) scale);