unity, GUIStyle and Skin
例1:
using UnityEngine;
using System.Collections;
using UnityEditor;
using System.Collections.Generic;
[CustomEditor(typeof(CmyScriptableObject))]
public class myScriptableObjectCustomEditor : Editor
{
public Vector2 scrollPosition = Vector2.zero;
public int selGridInt = 0;
public string[] selStrings = new string[] {"item1", "item2", "item3", "item4", "item5", "item6", "item7", "item8"};
public override void OnInspectorGUI()
{
DrawDefaultInspector ();
CmyScriptableObject data = CmyScriptableObject)target;
scrollPosition = EditorGUILayout.BeginScrollView (scrollPosition,"box",GUILayout.MaxHeight(90));
{
//ref: http://answers.unity3d.com/questions/37223/how-do-i-center-a-gui-label.html
//ref: http://iaimstar.iteye.com/blog/2222128
GUIStyle _style = GUI.skin.GetStyle ("MenuItemMixed");
selGridInt = GUILayout.SelectionGrid(selGridInt, selStrings, 1,_style);
}
EditorGUILayout.EndScrollView ();
}
}
例2:
using UnityEngine;
using System.Collections;
using UnityEditor;
using System.Collections.Generic;
[CustomEditor(typeof(CmyScriptableObject))]
public class myScriptableObjectCustomEditor : Editor
{
public Vector2 scrollPosition = Vector2.zero;
public int selGridInt = 0;
public string[] selStrings = new string[] {"item1", "item2", "item3", "item4", "item5", "item6", "item7", "item8"};
public override void OnInspectorGUI()
{
DrawDefaultInspector ();
CmyScriptableObject data = CmyScriptableObject)target;
scrollPosition = EditorGUILayout.BeginScrollView (scrollPosition,"box",GUILayout.MaxHeight(90));
{
//ref: http://answers.unity3d.com/questions/37223/how-do-i-center-a-gui-label.html
//ref: http://iaimstar.iteye.com/blog/2222128
GUIStyle _style = GUI.skin.GetStyle ("helpbox");
_style.onNormal.textColor=Color.blue;
selGridInt = GUILayout.SelectionGrid(selGridInt, selStrings, 1,_style);
}
EditorGUILayout.EndScrollView ();
}
}
自定义skin教程:http://forum.unity3d.com/threads/creating-custom-gui-skins-part-one.113055/
unity, GUIStyle and Skin的更多相关文章
- 王立平--Unity中间GUI Skin
C#文字: public class NewBehaviourScript2 : MonoBehaviour { public Texture t; public GUISkin skin; // U ...
- Unity编辑器中分割线拖拽的实现
GUI splitter control How can I make a GUI splitter control, similar to the splitter the console has? ...
- Unity编辑器的扩展:IMGUI
IMGUI 介绍 所有关于 Editor 的相关 UI,包括 Inspector.Hierarchy.Window.Game 视图上动态创建的那些半透明 UI.还有 Scene 视图上可添加的辅助显示 ...
- NetworkManager网络通讯_Example(一)
---恢复内容开始--- 用户手册,范例精讲. 用户手册上给出了一个简单的范例,并指出可以以此为基础进行相开发,再次对范例进行精讲.(NetworkManager对使用unity的轻量级游戏开发有很大 ...
- Unity-编辑器拓展之GUILayout,EditorGUILayout布局 { }
Unity 脚本 API 中文版 链接: https://docs.unity3d.com/cn/2019.4/ScriptReference/ 创建自定义窗口 public class MyWind ...
- 显示游戏FPS帧率的几种计算方式
FPSDisplay.cs using UnityEngine; using System.Collections; public class FPSDisplay : MonoBehaviour { ...
- 常见UI组件的一个模板
效果: 代码: using UnityEngine; using UnityEditor; using System.Collections; using System.IO; using Unity ...
- Unity编辑器:自定义编辑器样式——GUIStyle
通过GUIStyle,可以自定义Unity编辑器的样式. GUIStyle可以new一个全新的实例,这样,需要自己处理所有自己需要的效果. GUIStyle还可以基于已经存在的实例new一个新的实例, ...
- Unity编辑器扩展中,使用Unity自带的GUIStyle
在进行编辑器扩展时,创建组件的方法一般都会提供GUIStyle参数,可以让我们自定义样式.修改背景图,字体大小,颜色等等. 比如,创建Button组件的方法:public static bool Bu ...
随机推荐
- hibernate将connection放进threadlocal里实现数据库连接池
Why ThreadLocal? 无论如何,要编写一个多线程安全(Thread-safe)的程序是困难的,为了让线程共享资源,必须小心地对共享资源进行同步,同步带来一定的效能延迟,而另一方面,在处理同 ...
- debian下安装mysql
apt-get install mysql-client mysql-server 中间会要你设置password,设置后后就自己主动启动mysql了 能够用ps -ef|grep mysql 这样能 ...
- pytest文档10-命令行传参
前言 命令行参数是根据命令行选项将不同的值传递给测试函数,比如平常在cmd执行"pytest --html=report.html",这里面的"--html=report ...
- C#启动外部程序以及等待外部程序关闭的几种方法
1. 启动外部程序,不等待其退出. 2. 启动外部程序,等待其退出. 3. 启动外部程序,无限等待其退出. 4. 启动外部程序,通过事件监视其退出. // using System.Diagnosti ...
- 附1 consul常用命令+常用选项
之后每用到一个command或options,都会记录在这里. 常用命令command: agent 作用:运行一个consul agent join 作用:将agent加入到consul clust ...
- 关于OGRE与OSG的简单比较【转】
关于OGRE与OSG的简单比较 林乃养 lnychina{at}gmail.com 浙江大学CAD&CG实验室 2010年3月27日 1 前言 我曾经细致阅读过OGRE和OSG官方提供的文档, ...
- java学习笔记1--开发环境平台总结
本文地址:http://www.cnblogs.com/archimedes/p/java-study-note1.html,转载请注明源地址. 1.Java程序设计语言 Java程序设计语言是一种高 ...
- pjsip视频通信开发(底层实现)之用户注册(1)
一.PJSIP简介 对于pjsip的介绍可以看http://www.cnblogs.com/my_life/articles/2175462.html 文章,里面详细介绍了它的组成框架以及各部份的组成 ...
- table 中,如何使得单元格的内容不换行,单元格不被撑开
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...
- C-IDE使用指南
HI 您好: 亲爱的学员,本文章是基于C-IDE的入口使用指南,您能够查看demo项目来了解C-IDE详细操作哦~ 如有疑问您可提交反馈来咨询,或扫描下方二维码增加官方微信群.我们会认真对待且具体回 ...