使用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()
}