Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
Editor 编辑器
# Editor 编辑器 Inherits from [ScriptableObject](../ScriptableObject/ScriptableObject.html) Base class to derive custom Editors from. Use this to create your own custom inspectors and editors for your objects. 派生的自定义编辑器基类。使用这个为你的对象来创建自己的自定义检视面板和编辑器。 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"引用。 You can attach the Editor to a custom component by using the CustomEditor attribute. 你可以附加该编辑器到一个自定义组件,通过使用 CustomEditor 属性。 JavaScript Example: ``` // This example shows a custom inspector for an // object "MyPlayerEditor", which has two variables, vel (velocity) and ammo. //显示一个对象MyPlayerEditor的自定义检视面板,其中有两个变量vel (velocity) 和 ammo @CustomEditor(MyPlayerEditor) class MyPlayerEditor extends Editor { function OnInspectorGUI() { EditorGUILayout.BeginHorizontal (); EditorGUILayout.PrefixLabel ("Speed"); target.vel = EditorGUILayout.Slider(target.vel, 0, 100); EditorGUILayout.EndHorizontal (); EditorGUILayout.BeginHorizontal (); EditorGUILayout.PrefixLabel ("Ammo"); target.ammo = EditorGUILayout.IntField(target.ammo); EditorGUILayout.EndHorizontal (); } } ``` ### Variables**变量** * [target](Editor.target.html) The object being inspected. // 受检查的对象。 ### Functions**函数** * [DrawDefaultInspector](Editor.DrawDefaultInspector.html) Draw the built-in inspector. //绘制内置检视面板。 * [OnInspectorGUI](Editor.OnInspectorGUI.html) Implement this function to make a custom inspector. 执行这个函数来一个自定义检视面板。 * [Repaint](Editor.Repaint.html) Repaint any inspectors that shows this editor. 重绘显示在这个编辑器的任何检视面板。 * [HasPreviewGUI](Editor.HasPreviewGUI.html) Override this method in subclasses if you implement OnPreviewGUI. 如果执行 OnPreviewGUI,在子类重写这个方法。 * [OnPreviewGUI](Editor.OnPreviewGUI.html) Implement this method in a subclass if you want to have a preview field in the inspector. 如果你想在检视面板有一个预览字段,在子类执行这个方法。 * [OnPreviewSettings](Editor.OnPreviewSettings.html) Override this method if you want to show custom controls in the preview header. 如果你想在预览头显示自定义控件,重新这个方法。 * [GetInfoString](Editor.GetInfoString.html) Implement this method to show asset information on top of the asset preview. 执行这个方法来显示资源信息在资源预览的顶部。 ### Messages Sent**发送消息** * [OnSceneGUI](Editor.OnSceneGUI.html) Lets the Editor handle an event in the scene view. 让编辑器在场景视图处理一个事件。 ## Inherited members**继承成员** ### Inherited Variables**继承变量** * [name](../Object/Object.name.html) The name of the object. //物体的名字 * [hideFlags](../Object/Object.hideFlags.html) Should the object be hidden, saved with the scene or modifiable by the user? 物体是否被隐藏、保存在场景中或被用户修改? ### Inherited Functions**继承函数** * [GetInstanceID](../Object/Object.GetInstanceID.html) Returns the instance id of the object. 返回物体的实例 ID * [ToString](../Object/Object.ToString.html) Returns the name of the game object. 返回游戏物体的名称。 ### Inherited Class Functions**继承类函数** * [CreateInstance](../ScriptableObject/ScriptableObject.CreateInstance.html) Creates an instance of a scriptable object with className. 创建一个名为 className 的脚本化对象的一个实例。 * [CreateInstance.<T>](../ScriptableObject/ScriptableObject.CreateInstance.ltTgt.html) Creates an instance of a scriptable object with T. 创建一个带有 T 参数脚本化对象的实例。 * [operator bool](../Object/Object.operator_bool.html) Does the object exist? 物体是否存在? * [Instantiate](../Object/Object.Instantiate.html) Clones the object original and returns the clone. 克隆原始物体,并返回克隆的物体 * [Instantiate.<T>](../Object/Object.Instantiate.ltTgt.html) * [Destroy](../Object/Object.Destroy.html) Removes a gameobject, component or asset. 删除一个游戏物体、组件或资源 * [DestroyImmediate](../Object/Object.DestroyImmediate.html) Destroys the object obj immediately. It is strongly recommended to use Destroy instead. 立即销毁物体 obj,强烈建议使用 Destroy 代替。 * [FindObjectsOfType](../Object/Object.FindObjectsOfType.html) Returns a list of all active loaded objects of Type type. 返回 Type 类型的所有激活的加载的物体列表 * [FindObjectOfType](../Object/Object.FindObjectOfType.html) Returns the first active loaded object of Type type. 返回 Type 类型第一个激活的加载的物体。 * [operator ==](../Object/Object.operator_eq.html) Compares if two objects refer to the same 比较如果两个物体相同 * [operator !=](../Object/Object.operator_ne.html) Compares if two objects refer to a different object 比较如果两个物体不同 * [DontDestroyOnLoad](../Object/Object.DontDestroyOnLoad.html) Makes the object target not be destroyed automatically when loading a new scene. 加载新场景的时候使目标物体不被自动销毁。 ### Inherited Messages Sent**继承发送消息** * [OnEnable](../ScriptableObject/ScriptableObject.OnEnable.html) Creates an instance of a scriptable object with T. 创建一脚本化对象 T 的一个实例。 * [OnDisable](../ScriptableObject/ScriptableObject.OnDisable.html) This function is called when the scriptable object goes out of scope 当脚本化对象超出范围时调用这个函数。 * [OnDestroy](../ScriptableObject/ScriptableObject.OnDestroy.html) This function is called when the scriptable object will be destroyed. 当脚本化对象将被销毁,这个函数被调用。
da
2022年5月19日 23:06
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码