Unity3d 5.X UGUI学习 Button panel Scrollbar 游戏体SetActive ScrollRect 属性学习

panel Button 游戏体很简单 自己用几次就会了会绑定button事件就可

设置 this.gameObject.SetActive(true); 脚本在那个游戏体上就把它在游戏中激活

    public GameObject aboutPanel; //关于面板
    public GameObject commandPanel; //命令面板
    public GameObject debugPanel; //调试面板
    public GameObject currentPanel;//当前面板

   /// <summary>
    /// 打开关于面板
    /// </summary>
    public void OpendAbout() 
    {
        if (currentPanel != null && currentPanel != aboutPanel)
        {
            currentPanel.SetActive(false);
        }
        aboutPanel.SetActive(!aboutPanel.activeInHierarchy);
        currentPanel = aboutPanel;
    }


其中aboutPanel.activeInHierarchy 是表示aboutPanel在游戏中是否激活

aboutPanel.SetActive(!aboutPanel.activeInHierarchy); 表示如果在游戏中激活就关闭激活,如果没有激活就激活。

Scrollbar 滑块 应用

在Panel上添加ScrollRect 组件和mesh组件 之后在Panel 下面添加GameObject  Scrollbar 两个游戏体

调整Scrollbar 的方向及滑块方向。


即可


猜你喜欢

转载自blog.csdn.net/u010773333/article/details/52101351