效果:

代码:

 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;
}
}

常见UI组件的一个模板的更多相关文章

  1. Android常见UI组件之ListView(二)——定制ListView

    Android常见UI组件之ListView(二)--定制ListView 这一篇接上篇.展示ListView中选择多个项及实现筛选功能~ 1.在位于res/values目录下的strings.xml ...

  2. Android常见UI组件之ListView(一)

    使用ListView显示一个长的项列表 1.新建一个名为"BasicView5"的Android项目. 2.改动BasicView5.java文件.改动后的程序例如以下: pack ...

  3. 这是一个比较全的Android UI 组件

     Android组件及UI框架大全 原文地址:http://blog.csdn.net/smallnest/article/details/38658593 Android 是目前最流行的移动操作系统 ...

  4. 前端UI组件复用工具

    "懒"是第一生产力. 代码复用总是程序员喜闻乐见的,前端组件化的最终目的就是复用,今天我们就将深入探讨如何实现UI组件的复用. 通常我们所说的组件往往是包含业务逻辑的前端组件,而这 ...

  5. 学习通过Thread+Handler实现非UI线程更新UI组件

    [Android线程机制] 出于性能考虑,Android的UI操作并不是线程安全的,这就意味着如果有多个线程并发操作UI组件,可能导致线程安全问题.为了解决这个问题,Android制定了一条简单的规则 ...

  6. 学习通过Thread+Handler实现非UI线程更新UI组件(转)

    [Android线程机制] 出于性能考虑,Android的UI操作并不是线程安全的,这就意味着如果有多个线程并发操作UI组件,可能导致线程安全问题.为了解决这个问题,Android制定了一条简单的规则 ...

  7. 创建一个pre标签展开折叠的UI组件(原创)

    这些天练习UI组件的编写,顺便模仿一个h5版本的pre标签收缩展开的效果组件: 兼容ie8.9,谷歌,火狐: 图片效果如下: demo.html代码: <!DOCTYPE html> &l ...

  8. 创建一个自己的Vue UI组件库,并将它发布在npm上

    本文仅限于入门级,没有成规模制作,希望能对你有所帮助. 因为在开发多个项目中可能会用到同一个组件,那么我们通过复制粘贴的形式更新,无异于是笨拙的,我们可以通过上传到npm后,不断迭代npm包来实现更新 ...

  9. 2021 从零开始打造一个自己的 UI 组件库

    2021 从零开始打造一个自己的 UI 组件库 refs GUI https://github.com/xgqfrms/gui/ https://www.npmjs.com/package/@xgqf ...

随机推荐

  1. 阿里蚂蚁的前端ant-design

    蚂蚁国内镜像: http://ant-design.gitee.io/components/date-picker-cn/ 阿里的设计平台:https://design.alipay.com/deve ...

  2. Hive错误记录

    创建表报错 Error: Error while processing statement: FAILED: Execution Error, return code 1 from org.apach ...

  3. oracle sql试题

    转载 数据准备 create table student(  sno varchar2(10) primary key,  sname varchar2(20),  sage number(3),  ...

  4. eclipse自动添加作者、日期等注释

    使用eclipse的时候一般会添加自己的注释,标注日期作者等内容,我总结的添加注释的方式有两种:一.在新建class时自动添加注释:二.通过快捷键自动添加注释.下面分别描述一下添加方式. 一.新建cl ...

  5. HTML5 Canvas 龟羊赛跑

    从一张图上截取不同图块,动态显示在canvas上,形成赛跑的效果.完整代码图片下载请点击 https://files.cnblogs.com/files/xiandedanteng/turtleShe ...

  6. 编程算法 - 食物链 并查集 代码(C)

    食物链 并查集 代码(C) 本文地址: http://blog.csdn.net/caroline_wendy 题目: 有N仅仅动物, 分别编号为1,2,...,N. 全部动物都属于A,B,C中的一种 ...

  7. Visual Studio 外请版本号管理插件 - AnkhSVN

    Visual Studio 外请版本号管理插件 - AnkhSVN 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致 ...

  8. HTML 5 音频Audio

    在HTML5标准网页里面,我们能够运用audio标签来完毕我们对声音的调用及播放. 下面是最常常见到的运用HTML5三种基本格式: 1.最少的代码 <audio src="song.o ...

  9. ubuntu+let's encrypt生成永久免费https证书 ubuntu+tomcat+nginx+let's encrypt

    1. 下载let's encrypt $ sudo add-apt-repository ppa:certbot/certbot $ sudo apt-get update $ sudo apt-ge ...

  10. 《Microsoft Sql server 2008 Internals》读书笔记--第六章Indexes:Internals and Management(1)

    <Microsoft Sql server 2008 Internals>索引文件夹: <Microsoft Sql server 2008 Internals>读书笔记--文 ...