EditorWindow
- autoRepaintOnSceneChange
- BeginWindows
- Close
- EndWindows
- focusedWindow
- FocusWindowIfItsOpen.<T>
- FocusWindowIfItsOpen
- Focus
- GetWindow.<T>
- GetWindowWithRect.<T>
- GetWindowWithRect
- GetWindow
- mouseOverWindow
- OnDestroy
- OnFocus
- OnGUI
- OnHierarchyChange
- OnInspectorUpdate
- OnLostFocus
- OnProjectChange
- OnSelectionChange
- position
- RemoveNotification
- Repaint
- SendEvent
- ShowAuxWindow
- ShowNotification
- ShowPopup
- ShowTab
- ShowUtility
- Show
- Update
- wantsMouseMove
EditorWindow 编辑器窗口
Inherits from ScriptableObject
Derive from this class to create an editor window.
从这个类来创建编辑器窗口。
Note: This is an editor class. To use it you have to place your script in Assets/Editor inside your project folder. Editor classes are in the UnityEditor namespace so for C# scripts you need to add "using UnityEditor;" at the beginning of the script.
注意:这是一个编辑器类,如果想使用它你需要把它放到工程目录下的Assets/Editor文件夹下。编辑器类在UnityEditor命名空间下。所以当使用C#脚本时,你需要在脚本前面加上 "using UnityEditor"引用。
Create your own custom editor window that can float free or be docked as a tab, just like the native windows in the Unity interface.
创建自己的自定义编辑器窗口,可以自由浮动或作为一个标签停靠,就像在Unity接口的本地窗口。
Editor windows are typically opened using a menu item.
通常编辑器窗口是使用一个菜单项打开。
// C# example:
using UnityEngine;
using UnityEditor;
public class MyWindow : EditorWindow {
string myString = "Hello World";
bool groupEnabled;
bool myBool = true;
float myFloat = 1.23f;
// Add menu named "My Window" to the Window menu
[MenuItem ("Window/My Window")]
static void Init () {
// Get existing open window or if none, make a new one:
MyWindow window = (MyWindow)EditorWindow.GetWindow (typeof (MyWindow));
}
void OnGUI () {
GUILayout.Label ("Base Settings", EditorStyles.boldLabel);
myString = EditorGUILayout.TextField ("Text Field", myString);
groupEnabled = EditorGUILayout.BeginToggleGroup ("Optional Settings", groupEnabled);
myBool = EditorGUILayout.Toggle ("Toggle", myBool);
myFloat = EditorGUILayout.Slider ("Slider", myFloat, -3, 3);
EditorGUILayout.EndToggleGroup ();
}
}
// JavaScript example:
class MyWindow extends EditorWindow {
var myString = "Hello World";
var groupEnabled = false;
var myBool = true;
var myFloat = 1.23;
// Add menu named "My Window" to the Window menu
//添加菜单项My Window到Window菜单
@MenuItem ("Window/My Window")
static function Init () {
// Get existing open window or if none, make a new one:
//获取现有的打开窗口或如果没有,创建一个新的
var window : MyWindow = EditorWindow.GetWindow (MyWindow);
}
function OnGUI () {
GUILayout.Label ("Base Settings", EditorStyles.boldLabel);
myString = EditorGUILayout.TextField ("Text Field", myString);
groupEnabled = EditorGUILayout.BeginToggleGroup ("Optional Settings", groupEnabled);
myBool = EditorGUILayout.Toggle ("Toggle", myBool);
myFloat = EditorGUILayout.Slider ("Slider", myFloat, -3, 3);
EditorGUILayout.EndToggleGroup ();
}
}
Variables变量
-
Does the GUI in this editor window want MouseMove events?
GUI在这个编辑器窗口是否想要MouseMove事件? -
Does the window automatically repaint whenever the scene has changed?
每当场景改变,窗口自动重绘? -
The position of the window in screen space.
窗口在屏幕空间的位置。
Functions函数
-
Mark the beginning area of all popup windows.
标记所有弹出窗口的开始区域。 -
Close a window group started with EditorWindow.BeginWindows
关闭一个开始于EditorWindow.BeginWindows的窗口组。 -
Show a notification message.
显示一个通知消息。 -
Stop showing notification message.
停止显示通知消息。 -
显示Tab
-
Moves keyboard focus to this EditorWindow.
移动键盘焦点到这个编辑器窗口。 -
Show the EditorWindow as a floating utility window.
显示编辑器窗口,作为一个浮动工具窗口。 -
Used for popup style windows.
用于弹出类型窗口。 -
Show the EditorWindow.
显示编辑器窗口。 -
Show the editor window in the auxiliary window.
在辅助窗口中显示编辑器窗口。 -
Close the editor window.
关闭编辑器窗口。 -
Make the window repaint.
使窗口重绘。 -
Sends an Event to a window.
发送一个事件到窗口。
Messages Sent发送消息
-
Implement your own editor GUI here.
在这里实现自己的编辑器界面。 -
Called 100 times per second on all visible windows.
在所有可见的窗口每秒调用100次。 -
OnInspectorUpdate is called at 10 frames per second to give the inspector a chance to update
OnInspectorUpdate被调用,在给定检视面板每秒10帧更新。 -
OnDestroy is called when the EditorWindow is closed.
当编辑器窗口关闭时,OnDestroy被调用。 -
Called whenever the selection has changed.
只要选择发生改变时调用。 -
Called when the window gets keyboard focus.
当窗口获得键盘焦点时调用。 -
Called when the window loses keyboard focus.
当窗口失去键盘焦点时调用。 -
Called whenever the scene hierarchy has changed.
只要场景层级改变时调用。 -
Called whenever the project has changed.
只要项目被改变时调用。
Class Variables类变量
-
The EditorWindow which currently has keyboard focus (Read Only)
当前的哪一个编辑器窗口具有键盘焦点(只读)。 -
The EditorWindow currently under the mouse cursor (Read Only)
鼠标指针在当前的编辑器窗口之上(只读)。
Class Functions类函数
-
Returns the first EditorWindow of type t which is currently on the screen.
返回屏幕上类型t的当前的第一个编辑器窗口。 -
Returns the first EditorWindow of type T which is currently on the screen.
返回屏幕上类型T的当前的第一个编辑器窗口。 -
Focuses the first found EditorWindow of specified type if it is open.
如果是窗口打开的,焦点首先发现的指定类型的编辑器窗口。 -
Focuses the first found EditorWindow of type T if it is open.
如果是窗口打开的,焦点首先发现的类型T的编辑器窗口。 -
Returns the first EditorWindow of type t which is currently on the screen.
返回屏幕上当前类型t的第一个编辑器窗口。 -
Returns the first EditorWindow of type t which is currently on the screen.
Inherited members继承成员
Inherited Variables继承变量
-
The name of the object. //物体的名字
-
Should the object be hidden, saved with the scene or modifiable by the user?
物体是否被隐藏、保存在场景中或被用户修改?
Inherited Functions继承函数
-
Returns the instance id of the object.
返回物体的实例ID -
Returns the name of the game object.
返回游戏物体的名称。
Inherited Class Functions继承类函数
-
Creates an instance of a scriptable object with className.
创建一个名为className的脚本化对象的一个实例。 -
Creates an instance of a scriptable object with T.
创建一个带有T参数脚本化对象的实例。
-
Does the object exist?
物体是否存在? -
Clones the object original and returns the clone.
克隆原始物体,并返回克隆的物体 -
-
Removes a gameobject, component or asset.
删除一个游戏物体、组件或资源 -
Destroys the object obj immediately. It is strongly recommended to use Destroy instead.
立即销毁物体obj,强烈建议使用Destroy代替。 -
Returns a list of all active loaded objects of Type type.
返回Type类型的所有激活的加载的物体列表 -
Returns the first active loaded object of Type type.
返回Type类型第一个激活的加载的物体。 -
Compares if two objects refer to the same
比较如果两个物体相同 -
Compares if two objects refer to a different object
比较如果两个物体不同 -
Makes the object target not be destroyed automatically when loading a new scene.
加载新场景的时候使目标物体不被自动销毁。
Inherited Messages Sent继承发送消息
-
Creates an instance of a scriptable object with T.
创建一脚本化对象T的一个实例。 -
This function is called when the scriptable object goes out of scope
当脚本化对象超出范围时调用这个函数。 -
This function is called when the scriptable object will be destroyed.
当脚本化对象将被销毁,这个函数被调用。
最后修改:2011年8月20日 Saturday 18:36