How can I set the position and size of a sprite from inside a script ?

Hello, Unity Community.

I am currently developing a 2D game, and I want to know if it’s possible to set a sprite’s position and size from inside a script(C#). I looked at the Sprite.Create entry in the scripting API, but it lacks an example and it only helped confuse me.

It would help me design levels much easier by doing math rather than designing levels by eye in the editor.

It is possible.

public float width = 1;
public float height = 1;
public Vector3 position = new Vector3( 10, 5, 0 );

void Awake()
{
   // set the scaling
   Vector3 scale = new Vector3( width, height, 1f );
   transform.localScale = scale;
   // set the position
   transform.position = position;
}