Toggle、PopupList值的获取

点击“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("全屏改变");
    }
    //移动窗口
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值