一、创建编辑器窗口(EditorWindow) 1、创建继承自 EditorWindow 的类 MyWindow。(脚本必须放在“Editor”文件夹下) 2、在 MyWindow 的 OnGUI 函数中编写 GUI 控件。可使用 GUI、GUILayout、EditorGUI、EditorGUILayout类,并且可以随意混合搭配使用。 3、通过调用 EditorWindow.GetWindow(typeof(MyWindow)) 展示。
3)***Button:绘制按钮,响应单击事件 // 绘制带文本的按钮,单击抬起时返回true public static bool Button(Rect position, string text, GUIStyle style) // 绘制带图片的按钮,单击抬起时返回true public static bool Button(Rect position, Texture image, GUIStyle style) 1. 2. 3. 4. 4)RepeatButton:绘制一...
class in UnityEditor.UI / 继承自:UI.SelectableEditor描述 Button 组件的自定义编辑器。 扩展该类,为 Button 派生的组件编写自定义编辑器。另请参阅:Editor、CustomEditor。 公共函数 OnInspectorGUI 请参阅 Editor.OnInspectorGUI。 继承的成员 变量 serializedObject 表示正在检查的一个或多个对象的 SerializedObject...
using UnityEditor.Experimental.GraphView; using UnityEngine; namespace E.Story { // 单进单出节点 public class SingleInSingleOutNode : BaseNode { public override void Init(StoryGraphView graphView, string title, Vector2 position) { base.Init(graphView, title, position); // 重设属性默认值 Typ...
[MenuItem("MyEditor/Mybutton",false,0)] public static void OnClick() { Debug.Log("按下button"); } 2.在组件中添加按钮(右键列表)(测试组件BoxCollider) //必须在组件前面添加 CONTEXT组件标识 [MenuItem("CONTEXT/BoxCollider/TestCompent")] ...
Unity的Editor Window允许你创建自定义的编辑器工具来扩展Unity编辑器功能,提高工作流程效率。以下是开发自定义Editor Window的完整指南: 基本步骤 1. 创建基本的Editor Window csharp 复制 下载 using UnityEditor; using UnityEngine; public class MyCustomWindow : EditorWindow {// 添加菜单项[MenuItem("Tools/My...
用rootVisualElement 方法绘制按钮和用 GUILayout.Button 绘制按钮混用的案例 usingSystem.Collections;usingSystem.Collections.Generic;usingNUnit.Framework;usingUnityEditor;usingUnityEngine;usingUnityEngine.UIElements;publicclassMyTestPanel : EditorWindow {
Editor Scripting can help you customize and extend the Unity editor to make it easier to use on your projects. This tutorial covers the basics of editor scripting, including building custom inspectors, gizmos, and other Editor windows.
button. void OnWizardCreate() { } } 代码1-3 使用Editor Windows类进行扩展 完全自定义窗口,根据需求定义窗口内容和布局。使用时继承EditorWindow类,重写“OnGUI”函数。例子如代码1-4 using UnityEngine; using UnityEditor; public class MyWindow : EditorWindow { string myString = "Hello ...
用GUILayout或EditorGUILayout代替吧。示例有原因 BeginGUIBegin a 2D GUI block inside the 3D handle GUI. EndGUIEnda 2D GUI block and get back to the 3D handle GUI. Slider2DSlide a handle in a 2D plane. Camera类 没弄懂,文档里反复提到Camera.Current,似乎可以设置作为参数的camera为Current ...