Basically, I am from a Swift SpriteKit background where UIScreen.mainScreen().bounds is a CGRect which represents the screen and can be manipulated in various ways like getting the middle of the screen by using

var screenCenter = CGPointMake(UIScreen.mainScreen().bounds.width/2, UIScreen.mainScreen().bounds.height/2)

What is an equivalent of UIScreen.mainScreen().bounds in Unity (C# Scripting) that can manipulated to get various positions in a similar manner?


Sounds like you want the Screen class:

var screenCenter = new Vector2(
                       ) * 0.5f;

Note that this will give you the pixel coordinates of the center of the screen, in screenspace. To translate this into a position within the world coordinate system, you'll want to use something like Camera.ScreenToWorldPoint.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.