#Unity扩展
一 在Unity菜单栏中添加选项
1.必须再文件夹Editor脚本中写
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//引用命名空间
using UnityEditor;
public class EditorWin : EditorWindow{
string myString = "Hello World";
bool groupEnabled;
bool myBool = true;
float myFloat = 1.23f;
public EditorWin()
{
this.titleContent = new GUIContent("Menu");
}
[MenuItem("Tools/GoOn")]
static void InfoWindow()
{
GetWindow(typeof(EditorWin));
}
[MenuItem("Tools/Click")]
static void UserClick()
{
Debug.LogWarning("Click!");
}
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();
}
}
效果图