unity页面切换

一,功能:

做一个界面,点击继续,会弹出下一个界面。点击退出按钮,关闭界面。

如下图,Out和Contunue是两个按钮。

二:对于Image2和Image2(1)的设置:

 创建脚本Appear:

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

public class Apper : MonoBehaviour {

    public void Click()
    {
        print("你好");
        gameObject.SetActive(true);
    }
}

创建脚本disappear:

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

public class disapper : MonoBehaviour {

    //点击cube,显示image
    public void Click()
    { 
        gameObject.SetActive(false);
    }
}

将两个脚本拖到Image2和Image2(1)上。

 三,对于按钮Continue进行如下设置:

四,对于按钮Out进行如下设置: 

扫描二维码关注公众号,回复: 12441500 查看本文章

 这样就可以实现了。

猜你喜欢

转载自blog.csdn.net/Ciel_Y/article/details/105783302