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);
}
}
}
}
}
拿到脚本中变量名,根据变量名名称反向输出
最新推荐文章于 2021-07-09 18:30:05 发布