通过ToggleGroup实现关卡难度的选择

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class LevelChosse : MonoBehaviour {
    public GameObject toggleGroups;
    IEnumerable<Toggle> toggleGroup;

    void Update () {
      
        if (toggleGroup!=null)
        {
        toggleGroup = toggleGroups.GetComponent<ToggleGroup>().ActiveToggles();
            foreach (Toggle to in toggleGroup)
            {
                if (to.isOn)
                {
                    switch (to.name)
                    {
                        case "Toggle_Easy":
                            CollisonTest.Damage = 5;
                            break;
                        case "Toggle_normal":
                            CollisonTest.Damage = 10;
                            break;
                        case "ToggleP_diffcult":
                            CollisonTest.Damage = 20;
                            break;

                    }
                    break;
                }
            }
        }
      
		
	}                                 
}


阅读更多
文章标签: toggle level ui
个人分类: ui
上一篇Unity如何点击一个按钮实现界面的出现与消失
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭