ccruiの博客

ccruiの博客

简单的Unity全局弹窗方式

105
2022-03-27

简单的Unity全局弹窗方式

Unity版本2020.3.27f

WebGL示例

资源使用方式

  1. 直接克隆该项目
  2. 导入unitypackage包

使用方法

显示弹窗


PopupWindowControl.Instance.AccordingToPopupWindow(new PopupWindowControl.CC_PopupWindow()
        {
            Title = new PopupWindowControl.CC_Title()
            {
                TitleColor = new Color(1.0f,0.5f,0.5f,1.0f),
                TitleText = "示例标题",
                TitleTextColor = Color.white
            },
            Body = new PopupWindowControl.CC_Body()
            {
                BodyColor = new Color(1.0f,0.5f,0.5f,1.0f),
                BodyText = "示例内容",
                BodyTextColor = Color.white
            },
            Buttons = new List<PopupWindowControl.CC_Button>()
            {
                new PopupWindowControl.CC_Button()
                {
                    ButtonColor =new Color(1.0f,0.5f,0.5f,1.0f),
                    ButtonText = "确定",
                    ButtonTextColor = Color.white,
                    CallBack = (g =>
                    {
                        Debug.Log("按下按钮");
                        PopupWindowControl.Instance.ClosePopupWindow(g);
                    })
                },
                new PopupWindowControl.CC_Button()
                {
                    ButtonColor = Color.gray,
                    ButtonText = "取消",
                    ButtonTextColor = Color.white,
                    CallBack = (g =>
                    {
                        Debug.Log("按下按钮");
                        PopupWindowControl.Instance.ClosePopupWindow(g);
                    })
                }
            }
        });
        

关闭弹窗


PopupWindowControl.Instance.ClosePopupWindow(g);

演示视频

https://user-images.githubusercontent.com/57337795/160265258-99da2131-100a-44ed-89d9-fdcb6bb60dd6.mp4

您的浏览器不支持播放该视频!