拿到脚本中变量名,根据变量名名称反向输出
2015-03-02 15:20
162 查看
using UnityEngine; using System.Collections; using UnityEditor; using System.Reflection; public class YYFEasyToGetLV : EditorWindow { [MenuItem ("GameObject/Window")] static void AddWindow() { Rect wr = new Rect(0,0,500,1000); YYFEasyToGetLV window = (YYFEasyToGetLV)EditorWindow.GetWindowWithRect(typeof(YYFEasyToGetLV),wr,true,"window name"); window.Show(); } public GameObject father; public GameObject[] sons; public GameObject target; void OnGUI () { father = EditorGUILayout.ObjectField("father",father,typeof(GameObject),true) as GameObject; if(GUILayout.Button("GerLv",GUILayout.Width(200))) { this.ShowNotification(new GUIContent("You Have Get The Notification")); sons = new GameObject[father.transform.childCount]; for(int i = 0;i<sons.Length;i++) { sons[i]= father.transform.GetChild(i).gameObject; } this.ShowNotification(new GUIContent("This is a Notification")); } if(sons!=null) { GUILayout.Label("YES"); }else{ } target = EditorGUILayout.ObjectField("target",target,typeof(GameObject),true) as GameObject; if(target!=null) { if(target.GetComponent<PathEventListenner>()==null) { return; } FieldInfo[] members = target.GetComponent<PathEventListenner>().GetType().GetFields(); for(int i = 0;i<members.Length;i++) { GUILayout.Label(members[i].Name); if(GUILayout.Button(members[i].Name)) { Debug.Log(members[i].Name); members[i].SetValue(target.GetComponent<PathEventListenner>() ,sons); } } } } }
相关文章推荐
- 使用Groovy脚本引擎 根据表达式求值 或 反向解析构造对象
- 解剖Nginx·自动脚本篇(6)编译器名称变量脚本 auto/cc/name
- 根据SVN的MESSAGE进行多版本输出,反向排序,真是曲折~~~啊
- 编写程序,用if else语句根据姓名查询teaching数据库中学生的基本信息和选课信息,学生姓名通过变量输入。不存在则输出提示信息
- Photoshop脚本 > 根据图层名称查找图层
- sh脚本中同行输出同一变量的多个值
- python实现根据ip地址反向查找主机名称的方法
- shell 脚本中将输出内容赋值给一个变量时的换行问题
- 微软BI 之SSIS 系列 - 在 SSIS 输出平面文件时根据运行日期生成不同的文件名称
- PHP输出javascript脚本,带php参数,函数传参字符串并带有变量
- 解剖Nginx·自动脚本篇(6)编译器名称变量脚本 auto/cc/name
- ZendFramework学习第二章(视图脚本的变量调用形式和转义输出)
- SQLServer获得所有用户存储过程、根据存储过程名称获得内容、获得数据库对象创建脚本
- linux中的for、while循环输出中赋值变量及shell中循环获取脚本参数
- Linux Shell输出命令结果到脚本变量中
- shell 脚本中将输出内容赋值给一个变量时的换行问题
- ZendFramework学习第二章(视图脚本的变量调用形式和转义输出)
- [面试] 递归 反向输出链表 ,定义一个求字符串长度的函数, 反向输出字符串. 不能再函数内部定义变量.
- 解剖Nginx·自动脚本篇(6)编译器名称变量脚本 auto/cc/name
- python实现根据ip地址反向查找主机名称的方法