unity解像度

2088 ワード


#pragma strict
//////////////////////////////////////////////////////
///   .
//////////////////////////////////////////////////////
var w:int = 200;
var h:int = 30;
var t:int = 30;
var windowWidth:int = 200;
var windowHeight:int = 300;

private var isShow:boolean = false;

function OnGUI() {
	var index:int = 0;
	isShow = GUI.Toggle(Rect(10,10,100,20),isShow,isShow?SettingsText.strClose : SettingsText.strResolutionOption);
	
	if(isShow){
		index = ShowOptions(index);
		index ++;
		index = ShowFogSettings(index);
	}
	//info
	GUI.Label(Rect(210,10,200,30),"w:"+Screen.currentResolution.width+",h:"+Screen.currentResolution.height+",rate:"+Screen.currentResolution.refreshRate);
}
/**
	 
*/
private function ShowOptions(index:int){
	for(var res:Resolution in Screen.resolutions){
		if( GUI.Button(Rect(10,t + h * index,w,h),"w:"+res.width+",h:"+res.height+",rate:"+res.refreshRate) ){
			Screen.SetResolution(res.width,res.height,Screen.fullScreen);
		}
		index ++ ;
	}
	if(GUI.Button(Rect(10,t + index * h,w,h),Screen.fullScreen?SettingsText.strExitFullscreen : SettingsText.strEnterFullscreen)){
		Screen.fullScreen = !Screen.fullScreen;
	}
	return index;
}
//////////////////////////////////////////////////////
///  
//////////////////////////////////////////////////////
var hValue:float = 0.0;
var leftValue:float = 0.0;
var rightValue:float = 0.18;
private function ShowFogSettings(index:int){
	var pos:Rect = Rect(10,t + index * h,20,20);
	GUI.Label(pos,SettingsText.strFog);
		pos.x = pos.x + pos.width;
		pos.width = w - pos.x + 10;
		pos.height = h;
	hValue = GUI.HorizontalSlider(pos,hValue,leftValue,rightValue);
	
	RenderSettings.fog = true;
	RenderSettings.fogDensity = hValue;
	return index;
}