unity, inspector listview

inspector中实现列表框:

public override void OnInspectorGUI(){

bool isDoubleClick=false;
        Event e = Event.current;
        if (e.type == EventType.mouseDown && Event.current.button == 0) {//left button down
            if(e.clickCount==2){//double click
                isDoubleClick=true;
            }    
        }//got isDoubleClick

Rect scrollviewRect=EditorGUILayout.BeginVertical ();
        {
            scrollPosition = EditorGUILayout.BeginScrollView (scrollPosition, "box", GUILayout.Height (150));
            {
            
                //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");

m_selectIndex = GUILayout.SelectionGrid (m_selectIndex, list.ToArray (), 1, _style);
            }
            EditorGUILayout.EndScrollView ();
            if (scrollviewRect.Contains (e.mousePosition)) {
                if(isDoubleClick){
                   Debug.Log(list[m_selectIndex]);
                }
            }
        }
        EditorGUILayout.EndVertical ();

}

时间: 2024-08-02 00:44:49

unity, inspector listview的相关文章

扩展Unity Inspector

Unity Editor下,可以在不改变原有布局的情况下扩展Inspect的界面. 在继承了Editor的类中,有两种实现方式: using UnityEditor; [CustomEditor(typeof(CustomClass))] public class CustomClassEditor : Editor { public override void OnInspectorGUI() { // 自定义代码 base.OnInspectorGUI(); // 自定义代码 } } 和 u

unity, inspector debug

以前经常因为脚本中private变量不在inspector界面中显示,不方便观察其值的变化,所以本该用private的用了public. 今天发现,原来inspector有个选项,如图,平常勾选的是Normal,则inspector界面只显示public变量,如果改为勾选Debug,则private变量也会以灰字显示出来.

Unity Inspector 给组件自动关联引用(二)

通过声明的变量名称,主动关联引用. 使用这个关联引用两种方式1.  给你组件继承  MonoAutoQuote 点击组件inspector 按钮执行2.  给你组件类添加[AAutoQuote] 特性  通过Plateface/SetSelectGameRef 执行 [AAutoQuote] public class MonoAutoQuote : MonoBehaviour ,IAutoQuote{} public interface IAutoQuote { } public class A

unity inspector 自动装载Commont和Prefab属性

在使用unity的过程中,经常遇到这样的问题:每次都需要手动为序列化属性.像这样: 试着找了找,真的找到了一份代码,但是缺少自动装载Prefab的功能.之后我花了点时间添加这个功能. 使用方法: 1 [Autohook] 2 public Button SendBtn; 3 [Autohook] 4 public Button StartBtn; 5 [Autohook] 6 public Button LeaveBtn; 7 [Autohook] 8 public Text RoomDateT

Unity自定义mesh以及编译器

Star 自定义编辑器简易教程 an introduction to custom editors 原文地址 http://catlikecoding.com/unity/tutorials/star/ http://blog.csdn.net/lilanfei/article/details/7680802 简介 Introduction 这个教程将让你学会如何创建一个星型控件以及如何制作这个控件的自定义编辑器.你将学会: 动态的建立Mesh. 使用一个嵌套类. 建立一个自定义编辑器. 使用S

英特尔® 实感? SDK 前置摄像头 (F200) 常见问题解答

原文地址 https://software.intel.com/zh-cn/articles/intel-realsense-sdk-faq-for-front-facing-camera-f200?utm_source=cnblog&utm_medium=Social+Media&utm_campaign=Realsende_PRC_Q415_Syndication 该常见问题解答提供了英特尔® 实感™ SDK 黄金版 R1 和 R2 的硬件要求和特性信息. 要求 使用英特尔® 实感™

JSBinding / Code Snippets

new a gameobject & overloaded methds var go1 = new UnityEngine.GameObject.ctor(); var go2 = new UnityEngine.GameObject.ctor$$String("Hello"); add/get c# component var image = go.AddComponent$1(UnityEngine.UI.Image.ctor); var image = go.GetCo

Unity3D Shader之路 写Shader前必须要知道的事情 渲染流水线的概括

版本:unity 5.4.1  语言:Unity Shader 总起: 最近花了一个月的时间把<Unity Shader 入门精要>看完了,没怎么写博文,因为写得太好了,看得有点废寝忘食了,再次强烈推荐. 今天把写Shader前必须要知道的渲染流水线给概括一下,然后简单结合顶点\片元着色器Shader,说说各个代码在流水线的位置,以及职责功能. 渲染流水线: 在写Unity脚本的时候,不管是C#也好还是js也好,都是在跟CPU打交道,做算术运算.调用类成员.控制程序流程.而写Shader不同,

【Unity】2.7 检视器(Inspector)

分类:Unity.C#.VS2015 创建日期:2016-03-31 一.简介 Unity中的游戏是以包含网格.脚本.声音或灯光 (Lights) 等其他图形元素的多个游戏对象 (GameObjects) 组成.检视器 (Inspector) 显示当前所选游戏对象 (GameObjects) 的详细信息,包括所有附加组件 (Components) 及其属性. Inspector视图用于显示在游戏场景中当前所选择对象的详细信息,以及游戏整体的属性设置,包括对象的名称.标签.位置坐标.旋转角度.缩放