[CustomEditor(typeof(Original))]//表明挂载的是Original脚本publicclassMakeOriginalShowGUI:Editor{publicoverridevoidOnInspectorGUI(){base.OnInspectorGUI();boolisBool1 =false;boolisBool2 =false; isBool1 = EditorGUILayout.Toggle("Toggle", isBool1); isBool2 = GUILayout.Button("Button"); } } 可...
使用Unity编辑器类编辑 helpBox、Toggle、Button、Label 在Editor文件夹下创建脚本 usingUnityEngine;usingSystem.Collections;usingUnityEditor;[CanEditMultipleObjects][CustomEditor(typeof(TestScript))]publicclassEditorScript:Editor{privateTestScripttestScript;privateboolisTrue=true;privatevoidOnEnable(){testScript=(T...
一、创建编辑器窗口(EditorWindow) 1、创建继承自 EditorWindow 的类 MyWindow。(脚本必须放在“Editor”文件夹下) 2、在 MyWindow 的 OnGUI 函数中编写 GUI 控件。可使用 GUI、GUILayout、EditorGUI、EditorGUILayout类,并且可以随意混合搭配使用。 3、通过调用 EditorWindow.GetWindow(typeof(MyWindow)) 展示。
借助EditorButton 原来可以如此简单: usingSystem.Collections.Generic;usingUnityEngine;publicclassNewBehaviourScript:MonoBehaviour{[SerializeField]Transformtarget;[SerializeField]List<Transform>HidedCubes;//记录被隐藏的对象(必须被序列化在面板上,只有这样才会记录在YAML文件中)//演示测试 Random.Range API (返回随机数...
usingUnityEngine;usingUnityEditor; [CustomEditor(typeof(ObjectBuilderScript))]publicclassObjectBuilderEditor : Editor {publicoverridevoidOnInspectorGUI() { DrawDefaultInspector(); ObjectBuilderScript myScript=(ObjectBuilderScript)target;if(GUILayout.Button("创建对象")) { ...
方法如下在Editor脚本中添加GUILayout.Button即可: using UnityEngine; using UnityEditor; [CustomEditor(typeof(YourScript))] public class YourScriptEditor : Editor { public override void OnInspectorGUI() { //保留已有的样式 DrawDefaultInspector(); ...
UnityEditor.Sprites UnityEditor.UI Classes AnimationTriggersDrawer AspectRatioFitterEditor ButtonEditor CanvasScalerEditor ColorBlockDrawer ContentSizeFitterEditor DropdownEditor FontDataDrawer GraphicEditor GridLayoutGroupEditor HorizontalOrVerticalLayoutGroupEditor ImageEditor InputFieldEditor LayoutElementEditor MaskEditor...
class in UnityEditor / 继承自:EditorWindow 描述 从此类派生以创建编辑器向导。 编辑器向导通常使用菜单项打开。 // Creates a simple wizard that lets you create a LightGameObject// or if the user clicks in "Apply", it will set the color of the currently // object selected to red ...
public class ObjectBuilderEditor : Editor { public override void OnInspectorGUI() { DrawDefaultInspector(); ObjectBuilderScript myScript = (ObjectBuilderScript)target; if(GUILayout.Button("创建对象")) { myScript.BuildObject(); } } }
在编辑器顶部的ToolBar增加自定义的按钮,效果如下 代码如下,自取吧 效果就是,在编辑器下,不管你在什么场景,点击运行的时候,都会跳转到GameStart场景来启动 支持unity2018以上各种版本 #if UNITY_EDITOR us…