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);
}
}
}