点击“OPTIONS”进入下图“设置页面”
设置页面
总结://Toggle、PopupList不像Slide,能直接获取value值,需用“UIToggle.current.value”、“UIPopupList.current.value”来获取。
//“控制类型”、“难度等级”用UIPopupList.current.value获取的汉字字符串,需对应成程序能够识别的、自定义枚举变量(另注意,类开头需定义枚举变量,并且赋初值)。
using UnityEngine;
using System.Collections;
public enum ControllType
{
KeyBoard,
Mouse,
Touch
}
public enum DefficultLevel
{
Hard,
Normal,
Easy
}
public class GameControll : MonoBehaviour
{
public static GameControll instance;
public float volume=0.5f;
public ControllType ct = ControllType.KeyBoard;
public DefficultLevel dl = DefficultLevel.Normal;
public bool isFullScreen = false;
// Use this for initialization
void Start()
{
instance = this;
}
public void VolumeAdjust()
{
Debug.Log("音量改变");
volume=UIProgressBar.current.value;
}
public void ContollTypeAdjust()
{
Debug.Log("控制改变");
string kongzhi=UIPopupList.current.value;
Debug.Log(kongzhi);
switch (kongzhi)
{
case "键盘":
ct = ControllType.KeyBoard;
break;
case "鼠标":
ct = ControllType.Mouse;
break;
case"触摸":
ct = ControllType.Touch;
break;
}
}
public void DefficultLevelAdjust()
{
Debug.Log("难度改变");
string nandu = UIPopupList.current.value;
Debug.Log(nandu);
switch (nandu)
{
case "困难":
dl=DefficultLevel.Hard;
break;
case "一般":
dl = DefficultLevel.Normal;
break;
case "容易":
dl= DefficultLevel.Easy;
break;
}
}
public void isFullScreenAdjust()
{
Debug.Log(UIToggle.current.value);
//即isFullScreen=UIToggle.current.value;
if (UIToggle.current.value == true)
{
isFullScreen = true;
}
else
{
isFullScreen = false;
}
Debug.Log("全屏改变");
}
//移动窗口
}