GameObject scale in unity

How to increase / decrease the size of objects in Unity?

Example:

public GameObject sprite;

public float scale = 2.0f;

void ScaleResolution ()

{

sprite = sprite * scale; // epic string!

}

+3
source share
2 answers

This is a component property. transform

sprite.transform.localScale = new Vector3(2.0f, 2.0f, 2.0f);
+11
source

Position, rotation, and scale are transformation properties, so you need to change if:

public GameObject sprite;

public float scale = 2.0f;

void ScaleResolution()

{

sprite.transform.localScale = new Vector3(scale, scale, scale);
}
+1
source

All Articles