- Home /
window black content when resizing
How is it posible to "refresh", so to speak, the contents of a window when resizing it. It is only getting rendered correctly when windows resizing is released, but until then it shows a black background between the original windows size and the current. This is the code i'm using in the update function to resize the camera.
void Update()
{
if (lastScreenWidth != Screen.width || lastScreenHeight != Screen.height)
{
Resize();
lastScreenWidth = Screen.width;
lastScreenHeight = Screen.height;
}
}
void Resize()
{
float wantedAspectRatio = ((float)Screen.width / (float)Screen.height);
double roundedAspectRatio = System.Math.Round(wantedAspectRatio, 1);
double floorAspectRatio = System.Math.Floor(wantedAspectRatio);
if ((roundedAspectRatio >= AR_5_4) && (roundedAspectRatio < AR_4_3))
transform.GetComponent<Camera>().orthographicSize = Globals.CurrentBackgroundWidth / 2;
else
transform.GetComponent<Camera>().orthographicSize = (Globals.CurrentBackgroundWidth * 42f) / 100f;
}
Answer by HyunMok_Moon · Oct 17, 2016 at 05:00 AM
Is there a solution "refresh" or "redraw" during resizing window? During resizing window, Update() function is not called. We want to scale window contents(UI, textures, objects...) during resizing.
Your answer
![](https://koobas.hobune.stream/wayback/20220613101434im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Two seperate windows run one game 1 Answer
Resizing arrays, and what is the default array type anyway? 3 Answers
Resize Gui 1 Answer
Best way to do GUI related stuff? 1 Answer
How to resize Terrrain 1 Answer