Exemplo n.º 1
0
        public static void Init()
        {
            InventoryControllerWindow window = GetWindow <InventoryControllerWindow>("Controller");

            window.Show();
        }
Exemplo n.º 2
0
        public void OnGUI()
        {
            if (itemTarget == null)
            {
                return;
            }
            EditorGUILayout.LabelField(itemTarget.itemName);

            MemberTypes  mt = MemberTypes.Field | MemberTypes.Property | MemberTypes.Method;
            BindingFlags bf = BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic;

            MemberInfo[] members = itemTarget.GetType().FindMembers(mt, bf, (MemberInfo mi, object search) => true, null);

            EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            scrollPosItem = EditorGUILayout.BeginScrollView(scrollPosItem);
            foreach (MemberInfo mi in members)
            {
                var rect = GUILayoutUtility.GetRect(100, 20);
                rect.x     += 10;
                rect.width -= 20;
                InventoryControllerWindow.HR(rect);
                EditorGUI.LabelField(rect, mi.Name);
                rect.x += 200;
                InventoryControllerWindow.DrawLine(rect, 20);
                rect.width -= 205;
                rect.height = 18;
                try
                {
                    switch (mi.MemberType)
                    {
                    case MemberTypes.Field:
                        HandleField(mi as FieldInfo, rect);
                        break;

                    case MemberTypes.Property:
                        var prop = (mi as PropertyInfo).GetValue(itemTarget);
                        if (prop == null)
                        {
                            break;
                        }
                        EditorGUI.LabelField(rect, (mi as PropertyInfo).GetValue(itemTarget).ToString());
                        break;

                    case MemberTypes.Method:
                        var method = (mi as MethodInfo);
                        if (method == null)
                        {
                            break;
                        }
                        if (GUI.Button(rect, (mi as MethodInfo).Name))
                        {
                            MethodExecutor window = GetWindow <MethodExecutor>("Invoker");
                            window.Show();
                            window.mi          = method;
                            window.param       = new List <object>();
                            window.obj         = itemTarget;
                            window.returnValue = null;
                        }
                        break;
                    }
                }
                catch (Exception) { }
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
        }