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 specify the scale along the X, Y, and Z axes independently. Adjusting the local scale affects the size of the GameObject
in the scene, but does not impact its position or rotation.
Usage
To modify the local scale of a GameObject
, you can directly set the LocalScale
property with a new Vector3
value. This is useful for dynamically resizing objects in your scene based on game logic or user input.
Example
// Example of setting the local scale of a GameObject
GameObject myObject = new GameObject();
myObject.LocalScale = new Vector3(2.0f, 2.0f, 2.0f); // Sets the scale to double its original size in all directions
// Example of reading the local scale of a GameObject
Vector3 currentScale = myObject.LocalScale;
Console.WriteLine($"Current Local Scale: {currentScale}");