- Home /
create rect through script according to background image inside camera
I want to create a rect that is exactly the same position and size of my background image that is inside my camera. P.S. i created the rect Problem occurs when i change the resolution,because unity deosn,t change the size and position of the rect according to resolution
Answer by unity_GpbWbAdl2iFFOw · Jan 25, 2021 at 10:06 AM
rectR= new Rect(- cam.orthographicSize * Screen.width / Screen.height, -cam.orthographicSize, cam.orthographicSize * Screen.width / Screen.height, cam.orthographicSize*2);
rectL= new Rect(0,-cam.orthographicSize, cam.orthographicSize * Screen.width / Screen.height, cam.orthographicSize*2);
i created 2 rect left and right one according to the dimensions of the camera may be it helps you
Your answer
Follow this Question
Related Questions
Drawing a Circle instead of Rect 1 Answer
Finding the available space in a GUILayout. 2 Answers
[Answered]How to instantly draw rect in editor GUI for 2D tilemapper 1 Answer
adjust static position with rect like vectors 1 Answer
Hi, How do I modify the Preset from the Rect Transform's anchors by code? Thank you! 1 Answer