Performance: Transform component (position, rotation, scale)
This affects frame rendering speed and smoothness by how often and how complex the transform changes are processed in the scene graph.
Vector3 velocity = new Vector3(0.1f, 0, 0); void Update() { transform.position += velocity * Time.deltaTime; }
void Update() {
transform.position = new Vector3(transform.position.x + 0.1f, transform.position.y, transform.position.z);
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Direct position set every frame | N/A (scene graph nodes) | 1 matrix recalculation per frame | Low | [X] Bad |
| Using velocity with Time.deltaTime | N/A | 1 matrix recalculation per frame | Low | [OK] Good |
| Euler angle conversion every frame | N/A | 2 conversions + 1 matrix recalculation | Medium | [X] Bad |
| Using transform.Rotate incremental | N/A | 1 matrix recalculation | Low | [OK] Good |
| New Vector3 allocation every frame for scale | N/A | 1 matrix recalculation + GC pressure | Medium | [X] Bad |
| Reusing Vector3 instance for scale | N/A | 1 matrix recalculation | Low | [OK] Good |
Transform.position property control in a Unity GameObject?position property specifically sets the object's location in 3D space.transform.localScale, not transform.scale.new Vector3(2, 2, 2) doubles size in all directions.transform.position = new Vector3(1, 2, 3); transform.position += new Vector3(0, 1, 0); Debug.Log(transform.position);
transform.rotation = Quaternion.Euler(0, 90);
Update(). Which code snippet correctly updates the scale each frame?transform.localScale = Vector3.Lerp(current, target, Time.deltaTime) updates scale smoothly each frame.Pass the test and this pattern moves unknown