NeoKuro
NeoKuro

Reputation: 457

How to refresh screen after screen resolution change?

I've managed to get my game to change it's resolution at runtime/whilst in the game (after the initial choice). However I've noticed that when going from say 1920x1080 to say 800x600, I get a border on the sides of the previous image/content that was there.

For example, my menu is displayed on the far right, when downsized to 800x600, the menu on the far right remains, but is non-interactable (its just an image) whereas the 'actual menu' is several hundred pixels to the left.

What I'm asking is is there a way to make it so the sides of my game are just black when someone changes the resolution? If it'd help I can provide images of what I am on about :)

Upvotes: 1

Views: 1448

Answers (1)

NeoKuro
NeoKuro

Reputation: 457

Solved it. My initial attempt at simply 'resetting' the screen with a black Quad failed for some reason. But after trying again this seemed to work.

By creating a quad (or texture) and setting the colour to black (or whatever other colour you wish to set the screen to) and moving it out the way, when the screen resolution is called I simply transform the position of the Texture/Quad to cover the canvas/screen, I then reload the level, and set the resolution to the newly chosen one, and reload my menu. The code below shows it in case anyone else has the same problem I did.

This seems to have worked fine, and can be repeated however many times the user wants.

public void ApplyResolutionChange (GameObject menu)
{       
        GameObject blank = GameObject.Find ("BlankScreen");

        blank.transform.position = new Vector3 (0, 0, 100);
        Application.LoadLevel (0);
        Screen.SetResolution (resolutionX, resolutionY, isFullscreen);
}

Upvotes: 2

Related Questions