Unity之EditorWindow-Notification-六

使用Unity编辑器类创建窗口,在窗口上显示 Notification 通知








在Editor文件夹下创建脚本如下

using UnityEngine;
using System.Collections;
using UnityEditor;

public class EditorWindowTest : EditorWindow {

    string notification = "This is a Notification";  //通知内容

    [MenuItem("Example/Notification usage")]
    static void Init()
    {
        EditorWindowTest window = (EditorWindowTest)EditorWindow.GetWindow(typeof(EditorWindowTest));
        window.Show();
    }

    void OnGUI()
    {
        notification = EditorGUILayout.TextField(notification);

        if (GUILayout.Button("Show Notification"))
        {
            this.ShowNotification( new GUIContent(notification)); //调用该方法发送通知
        }

        if (GUILayout.Button("Remove Notification"))
        {
            this.RemoveNotification();  //取消通知
        }
}

  void OnInspectorUpdate()  //该方法每秒调用 10 帧
    {
        this.Repaint();
    }

  void OnHierarchyChange()  //当Hierarchy面板发生变化时,调用该方法
    { 
    
    }

    void OnProjectChange() //当 Project 面板发生变化时调用该方法
    { 
    
    }


void OnSelectionChange() //当选择的对象改变时调用该方法
    { 
    
    }

void Update()  //每秒调用 100 次
    { 
        
    }
    //autoRepaintOnSceneChange()

}

















  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值