unity提示消息窗口

这篇博客介绍了如何在Unity中创建一个自用的提示消息窗口。内容包括预制体的准备和框架的注意事项,特别是资源加载的调整。
摘要由CSDN通过智能技术生成

本贴是自用提示消息窗口,仅供参考。

1.首先要有一个提示消息框的预制体。

2.本框架注意加载资源的地方需要改一下。

MessageBox

sing UnityEngine ;

/// <summary>
/// 通用对话框通用类
/// </summary>
public class MessageBox : MonoBehaviour
{
    public delegate void MessageDelegate( System.Object obj);
    public MessageDelegate OkClick ;
    public MessageDelegate CancelClick ;

    private string customTextOK ;
    public string TextOK
    {
        get { return textOK. text; }
        set
        {
            textOK.text = value;
            customTextOK = value ;
        }
    }

    private string customTextCancel ;
    public string TextCancel
    {
        get { return textCancel. text; }
        set
        {
            textCancel.text = value;
            customTextCancel = value ;
        }
    }

    public int WidthOK
    {
        get { return widgetOK. width; }
        set
        {
            widgetOK.width = value;
        }
    }

    public int WidthCancel
    {
        get { return widgetCancel. width; }
        set
        {
            widgetCancel.width = value;
        }
    }

    public string Content
    {
        get { return content. text; }
        set
        {
            content.text = value;
        }
    }

    public int WitdhContent
    {
        get { return content. width; }
        set
        {
            content.width = value;
        }
    }

    public int StartingRenderQueue
    {
        get { return uiPanel. startingRenderQueue; }
        set
        {
            uiPanel.startingRenderQueue = value;
        }
    }

    public UIWidget.Pivot ContentPivot
    {
        get { return content. pivot; }
        set
        {
            content.pivot = value;
        }
    }

    // 延迟启用确定按钮
    private float delayOkTime = 0;
    public float DelayOkTime
    {
        get { return delayOkTime; }
        set
        {
            delayOkTime = value ;
        }
    }

    // 延迟启用取消按钮
    private float delayCancelTime = 0;
    public float DelayCancelTime
    {
        get { return delayCancelTime; }
        set
        {
            delayCancelTime = value ;
        }
    }

    public enum Type
    {
        OK,
        OKCancel,
        Custom1Btn,         // 自定义一个按钮
        Custom2Btn,         // 自定义两个按钮
    };
    public Type type { get; private set; }
    // 点背景是不是可以关闭对话框
    public bool CanCloseByFadeBGClicked = true;
    // 点击背景是否关闭对话框,只是关闭,不执行其他
    public bool I
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值