Quantcast
Channel: Questions in topic: "screen size"
Viewing all articles
Browse latest Browse all 225

Please help me understand this code

$
0
0
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

Viewing all articles
Browse latest Browse all 225

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>