(Solved) SetResolution different Scenes

Hello,

I have different scenes that i want to set the resolution for by using a dropdown menu. How can i do this?

I found a dropdown menu code here on the website that i changed for this. It works on 1 scene, but i want it to change on more scenes.

Code:

// DropDownMenuPier.js

// Written by Pier Shaw
//you can use or mod this file anyway you like and if you make something cool out of it
// and like to share it send it to 
//just add it to a cam or empty gameObject

// to add buttons just Repeat what you see
@script ExecuteInEditMode() 
private var Ypos1 : float = 130.0;
private var Ypos2 : float = 130.0;
private var Ypos3 : float = 130.0;
private var Ypos4 : float = 130.0;

var GameObject : GameObject; 

private var showDropdownButtons1 : boolean;
private var showDropButtonsUP1 : boolean;

var dropSpeed : float = 400.0;// if you like change the speed



function Update(){
	
	if(showDropdownButtons1 == true){
	
		Ypos1 += Time.deltaTime * dropSpeed;
		Ypos2 += Time.deltaTime * dropSpeed;
		Ypos3 += Time.deltaTime * dropSpeed;
		Ypos4 += Time.deltaTime * dropSpeed;
		
		if(Ypos1 >= 160){
			Ypos1 = 160;
			}
				
			if(Ypos2 >= 190){
				Ypos2 = 190;
				}
		
				if(Ypos3 >= 220){
					Ypos3 = 220;
					}
			
					if(Ypos4 >= 250){
						Ypos4 = 250;
						}
						
	
if(showDropButtonsUP1 == true){
			Ypos1 -= Time.deltaTime * dropSpeed;
			Ypos2 -= Time.deltaTime * dropSpeed;
			Ypos3 -= Time.deltaTime * dropSpeed;
			Ypos4 -= Time.deltaTime * dropSpeed;
			
			if(Ypos1 >= 130 || Ypos2 >= 130 || Ypos3 >= 130 || Ypos4 >= 130){
			Ypos1 = 130;
			Ypos2 = 130;
			Ypos3 = 130;
			Ypos4 = 130;
			showDropButtonsUP1 = false;
			showDropdownButtons1 = false;
			}	
}					
						
}

}

// you can change anything in red
function OnGUI (){

GUI.Label( Rect(20,130,300,100), "Screen Size"); 
if(showDropdownButtons1 == false){	
if (GUI.RepeatButton (Rect (300, 130, 100, 30), "Screen Size")){
	showDropdownButtons1 = true;				
}
}




if(showDropdownButtons1 == true){
	
			if (GUI.Button (Rect (300, 130, 100, 30), "Screen Size")){
				showDropButtonsUP1 = true;
				showDropdownButtons1 = false;	
			}
		
			if (GUI.Button (Rect (300, Ypos1, 100, 30), "640 x 480")){
		   	showDropButtonsUP1 = true;
		    showDropdownButtons1 = false;
			Screen.SetResolution (640, 480, true); 
			}
			
			if (GUI.Button (Rect (300, Ypos2, 100, 30), "800 x 600")){
			showDropButtonsUP1 = true;
			showDropdownButtons1 = false;
			Screen.SetResolution (800, 600, true);
		    }
		    
		    if (GUI.Button (Rect (300, Ypos3, 100, 30), "1024 x 768")){
			showDropButtonsUP1 = true;
			showDropdownButtons1 = false;
			Screen.SetResolution (1024, 768, true);
		    }
		    
		    if (GUI.Button (Rect (300, Ypos4, 100, 30), "1900	x 1200")){
			showDropButtonsUP1 = true;
			showDropdownButtons1 = false;
			Screen.SetResolution (1900, 1200, true);
		    }
		

}	

}

I still didn’t got the answer for this, but was thinking. Because i have only 2-3 scenes, but the important scene is only 1. Could i also do it with layers? Or is it better to try the above technologie?

And how i can achieve this above? I have tried several things this day and still don’t get it :cry:
It isn’t that hard to change things in other scenes i hope :roll:

What is going wrong when you try to change resolution in the other scenes?

I think that is the problem. I set for the option Menu scene the resolution. But then i go back to my game scene and there is the resolution normal again.

So i need to change the resolution for all scenes and not only the scene that i change it.

For example i want this: (but this don’t works)
Menu.Screen.SetResolution (640, 480, true);
Options.Screen.SetResolution (640, 480, true);

So above translated: the menu and the option screen needs to go to 640 by 480. This happens if i set the dropdown menu on 640 by 480. And even easier is that just all scenes go to 640 by 480 if i click on it.

But the problem is that i dont know how i can call another scene and directly change the resolution, because it only does the resolution of the active scene.

Hope it is now clear what i want. I still didn’t got it.

Gr. Sneakyman

You’re right, you can’t change the resolution for another scene. What you need to do is store the settings in an object on the menu scene and mark that object with Object.DontDestroyOnLoad. The object will then be available when the new scene starts and so you can get the resolution settings from the object and set them up.

Got it finally working :lol:

Thanks :smile: