CustomEditor属性告知Unity哪个组件需要表现为编辑器 OnInspectorGUI方法中的代码,当Unity在Inspcetor中显示这个编辑器时执行。你可以在这里放入任何GUI代码--它的工作和游戏中的OnGUI方法类似,只不过它是在Inpector中执行,Editor定义了target属性,以便让你能够获得被检视的对象。 通过检查GUI.changed,如果发现用户修改了...
Framework { [Serializable] public class ViewVisibilityChangedEvent { public UIAnimation animation = new UIAnimation(); public UnityEvent onBeginEvent; public UnityEvent onEndEvent; } } 代码语言:javascript 复制 为UI View创建Custom Editor: 代码语言:javascript 复制 using System; using UnityEngine; using...
默认式样 这些功能都不错,但我们还可以使 Unity 工作的更好。我们通过在 Editor/ 下创建 LookAtPointEditor.cs 脚本。 [CustomEditor(typeof(LookAtPoint))][CanEditMultipleObjects]publicclassLookAtPointEditor:Editor{SerializedPropertylookAtPoint;voidOnEnable(){// 获取到 lookAtPoint 成员属性lookAtPoint=serial...
简介: Unity 编辑器开发实战【Custom Editor】- 为UI视图制作动画编辑器 为了更方便地为UI视图添加动画,将动画的编辑功能封装在了UI View类中,可以通过编辑器快速的为视图编辑动画。动画分为两种类型,一种是Unity中的Animator动画,该类型直接通过一个字符串类型变量记录动画State状态的名称即可,播放时调用Animator类中...
The next step is to create a Custom Editor for script we just created.When you create a script in Unity, by default it inherits from MonoBehaviour, and therefore is a Component which can be placed on a game object. When placed on a game object, the Inspector displays a default interface...
动画分为两种类型,一种是Unity中的Animator动画,该类型直接通过一个字符串类型变量记录动画State状态的名称即可,播放时调用Animator类中的Play方法传入该名称。另一种是DoTween动画,支持视图的移动、旋转、缩放、淡入淡出动画的编辑:首先看一下动画相关的几......
自定义编辑器类继承Editor类后,重写OnInspectorGUI函数来自定义Inspector面板,例如添加一个Label文本: 代码语言:javascript 复制 using UnityEngine;using UnityEditor;namespaceSK.Framework{[CustomEditor(typeof(FSMMaster))]publicclassFSMEditor:Editor{publicoverridevoidOnInspectorGUI(){GUILayout.Label("有限状态机")...
首先继承自Editor类,使用CustomEditorAttribute,并重写OnInspectorGUI方法以实现自定义编辑器。 音频库名称是一个string类型字段,因此使用EditorGUILayout中的TextField函数来添加一个文本编辑框: usingUnityEditor;usingUnityEngine;[CustomEditor(typeof(AudioDatabase))]publicclassAudioDatabaseEditor:Editor{privateAudioDataba...
对编辑器属性操作,需要继承PropertyDrawer类,同时还依赖UnityEditor命名空间。类名上加上[CustomPropertyDrawer(typeof(FloatRange))],告诉Unity这是一个CustomPropertyDrawer,并且typeof(FloatRange)指定是FloatRange类型的CustomPropertyDrawer; usingUnityEngine;usingUnityEditor;//编辑器依赖//告诉Unity要创建FloatRange类型的...
Unity 编辑器开发实战【Custom Editor】- FSM Editor 本文介绍如何为FSM有限状态机模块实现一个自定义编辑器面板 首先,自定义一个编辑器面板,需要用到Attribute:CustomEditor,参数传入目标类的类型,代码如下: usingUnityEngine;usingUnityEditor;namespaceSK.Framework{[CustomEditor(typeof(FSMMaster))]publicclassFSMEditor...