今天我们就来学习如何创建一个编辑框,上面绘制一个折叠框里面有四种消息框.
代码如下:
using UnityEngine; using System.Collections; using UnityEditor; public class Test : EditorWindow { private bool foldoutType; [MenuItem("plateface/CreateWindows")] static void CreateWinodw() { //在这里创建窗口 EditorWindow.GetWindow(typeof(Test),false,"EditorWindow",true); } void OnGUI() { //绘制折叠框 foldoutType = EditorGUILayout.Foldout (foldoutType,"Foldout"); //绘制成功就继续绘制 if(foldoutType) { EditorGUILayout.HelpBox("你创建了一个错误信息", MessageType.Error); EditorGUILayout.HelpBox("HelpBox", MessageType.Info,false); //不占据一行显示 EditorGUILayout.HelpBox("HelpBox", MessageType.None); EditorGUILayout.HelpBox("HelpBox", MessageType.Warning); } foldoutType = EditorGUILayout.Foldout (foldoutType,"属性"); //绘制成功就继续绘制 if(foldoutType) { EditorGUILayout.HelpBox("你创建了一个错误信息", MessageType.Error); } } }
效果图: