I am new to Unity and coding but since I am learning and highly interested, I am trying to understand things as much as possible. I am following a tutorial I have purchased which used this code but I am not able to understand what happened. I request the awesome community here to please comment the lines so that I can understand what happened in this code.
SpriteRenderer sr = GetComponent ();
Vector3 tempScale = transform.localScale;
float width = sr.sprite.bounds.size.x;
float worldHeight = Camera.main.orthographicSize * 2f;
float worldWidth = worldHeight / Screen.height * Screen.width;
tempScale.x = worldWidth / width;
transform.localScale = tempScale;
PS: this code is used to resize the background image to fit the screen size
↧