效果:

代码:

 using UnityEngine;
using UnityEditor;
using System.Collections;
using System.IO;
using UnityEngine.SceneManagement; public class Test: EditorWindow
{
[MenuItem("地图/测试")] static void AddWindow()
{
//创建窗口
Test window = (Test)EditorWindow.GetWindow(typeof(Test), false, "test");
window.Show(); } enum RGB
{
red,
green,
blue
} RGB rgb; private int selectedMethod;
bool IsFoldOut;
string folderpath; bool toggle_1;
bool toggle_2;
bool toggle_3; void OnGUI()
{
// if (GUILayout.Button("test"))
// {
// Debug.Log("test"); // }
//最上分栏的小按钮,系统自带图标名称链接:http://www.xuanyusong.com/archives/3777
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUIStyle buttonStyle;
buttonStyle = new GUIStyle(UnityEditor.EditorStyles.miniButtonLeft);
if (selectedMethod == )
buttonStyle.normal.background = buttonStyle.onActive.background;
if (GUILayout.Button(EditorGUIUtility.IconContent("TerrainInspector.TerrainToolRaise"), buttonStyle))
{ selectedMethod = ;
}
buttonStyle = new GUIStyle(UnityEditor.EditorStyles.miniButtonRight);
if (selectedMethod == )
buttonStyle.normal.background = buttonStyle.onActive.background;
if (GUILayout.Button(EditorGUIUtility.IconContent("TerrainInspector.TerrainToolSetheight"), buttonStyle))
{ selectedMethod = ;
}
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
//说明栏
EditorGUILayout.BeginVertical(GUI.skin.box);
GUILayout.Label("这是一个说明栏", EditorStyles.wordWrappedLabel);
EditorGUILayout.EndVertical(); //枚举pop
rgb =(RGB) EditorGUILayout.EnumPopup("rgb枚举",rgb); //收起控件
IsFoldOut = EditorGUILayout.Foldout(IsFoldOut, "展开控件");
if (IsFoldOut)
{
EditorGUILayout.LabelField(new GUIContent("hello"));
}
//打开文件夹
EditorGUILayout.BeginHorizontal();
GUILayout.Label("打开文件夹:");
folderpath = EditorGUILayout.TextField(folderpath);
if (GUILayout.Button("浏览"))
{ EditorApplication.delayCall += OpenFolder; }
EditorGUILayout.EndHorizontal(); GUIStyle labStyle = new GUIStyle(UnityEditor.EditorStyles.label);
labStyle.fontSize = ;//设置字体大小
labStyle.fontStyle = FontStyle.Bold;//设置粗体
labStyle.alignment = TextAnchor.MiddleCenter;//字体垂直居中
labStyle.normal.textColor =Color.red;//字体颜色
GUILayout.Label(new GUIContent("GUILayout.Label"),labStyle); GUIStyle btnStyle = new GUIStyle(GUI.skin.GetStyle("Button"));
btnStyle.normal.textColor = Color.red;//修改按钮字体颜色
//btnStyle.normal.background
if (GUILayout.Button("GUILayout.Button", btnStyle))
{ } EditorGUILayout.BeginToggleGroup("勾选框",true); EditorGUILayout.EndToggleGroup();
// GUIStyle btnStyle = new GUIStyle(GUI.skin.GetStyle(""));
// GUIStyle buttonStyle= new GUIStyle(UnityEditor.EditorStyles.label);
// EditorGUILayout.LabelField(new GUIContent("EditorGUILayout.LabelField"));
this.Repaint();
} void OpenFolder()
{
string scenePath = SceneManager.GetActiveScene().path;
string path = EditorUtility.OpenFolderPanel("选择文件夹", "","");
if (path.Length == )
return;
folderpath = path;
}
}

最新文章

  1. IDDD 实现领域驱动设计-CQRS(命令查询职责分离)和 EDA(事件驱动架构)
  2. 『TCP/IP详解——卷一:协议』读书笔记——16
  3. nginx的Location的总结以及rewrite规则的总结
  4. (转)Thread.setDaemon设置说明
  5. 【轻院热身赛】级数求和、进制转换、candy
  6. 一起啃PRML - 1.2.1 Probability densities 概率密度
  7. 转:Twitter.com在用哪些Javascript框架?
  8. decimal ? 含义
  9. 利用 MUI开发app, 如何实现侧滑菜单及其主体部分上下滑动
  10. Fedora 下 Google-Chrome 经常出现僵尸进程的权宜办法
  11. MySQL MERGE存储引擎
  12. FastSocket客户端/服务端通讯示例 客户端被动接收
  13. 学习excel的使用技巧统计文本出现的次数
  14. Git安装配置,和使用的简介
  15. Git使用一:git客户端安装与创建用户
  16. Win10系列:C#应用控件基础23
  17. 通过写一个Demo展示C#中多种常用的集合排序方法
  18. .NET Reflector v9.0.1.318(包含注册机)
  19. lightoj1132—Summing up Powers (取膜技巧&&组合数应用)
  20. [BZOJ1935][SHOI2007]Tree 园丁的烦恼(树状数组)

热门文章

  1. Winform打砖块游戏制作step by step第7节---碰撞检测
  2. DTU
  3. hibernate,mybatis,beetlsql 全面比較
  4. ckeditor的详细配置(转)
  5. 线性判别分析(Linear Discriminant Analysis, LDA)算法初识
  6. Jakarta雅加达项目简介
  7. linux中grep命令
  8. angular 中的$event 对象包含了浏览器原生的event对象
  9. 2017.4.10 spring-ldap官方文档学习
  10. Angular 学习笔记——ng-repeat&filter