Description
The LocalScale
property of a GameObject
represents the scale of the object relative to its parent. This property is a Vector3
type, allowing you to define the scale in the X, Y, and Z dimensions independently. Modifying this property will affect the size of the GameObject
in the local space, which is particularly useful for scaling objects without affecting their global scale directly.
Usage
To use the LocalScale
property, you can directly get or set its value on a GameObject
instance. This is useful when you need to adjust the size of an object in relation to its parent or when you want to animate the scale of an object over time.
Example
// Example of setting the local scale of a GameObject
GameObject myObject = new GameObject();
myObject.LocalScale = new Vector3(2.0f, 2.0f, 2.0f); // Doubles the size of the object in all dimensions
// Example of getting the local scale of a GameObject
Vector3 currentScale = myObject.LocalScale;
Console.WriteLine($"Current Local Scale: {currentScale}");