- Home /
How to get an object to fill 3/4th of the screen.
Hi, I'm pretty new to Unity and coding in general and I've run into a bit of a problem. I currently have a GUI menu for the player on the right 1/4th of the screen and am currently trying to get a plane that I intend to use as the game board to fill the remaining part of the screen. I assign the plane to the board object, but its scale remains 1 regardless. I also can't figure out how to get it to default to the top left of the screen. I am trying to use the following code:
void screenPos()
{
Vector3 temp = transform.position;
temp.x = -(board.transform.localScale.x/2);
board.transform.position = temp;
}
void fitScreen()
{
Vector3 temp = transform.localScale;
temp.x = (Screen.width)/4;
board.transform.localScale = temp;
}
I figured that I would be able to use the same method that I used to get the GUI to show up on the right 1/4th of the screen, but when I try to use the methods above it returns the values for Screen.width/4 as 229 while using the Standalone View window. Any help would be appreciated, I'm pretty well stumped on what to do.
Your answer
Follow this Question
Related Questions
Extraction of Coordinate and Scaling it down by half. 1 Answer
scaling objects with rigidbodies 2 Answers
[Android] Screen Scaling?! 0 Answers
How can I instantiate an object without using Unity? 1 Answer