Ejemplo n.º 1
0
        private TreeNode AddCompontNode(TreeNodeCollection rootNode, Component component)
        {
            if (component.GetType().GetCustomAttribute <HideInInspector>() != null)
            {
                return(null);
            }
            TreeNode cNode = AddNode(rootNode, component.GetType().FullName);

            if (component.Enable)
            {
                cNode.ForeColor = System.Drawing.Color.Blue;
            }
            else
            {
                cNode.ForeColor = System.Drawing.Color.Gray;
            }


            //属性默认显示
            BindingFlags flag = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;

            foreach (PropertyInfo pInfo in component.GetType().GetProperties(flag))
            {
                HideInInspector inspectorF = pInfo.GetCustomAttribute <HideInInspector>();
                if (inspectorF != null)
                {
                    continue;
                }
                AddNode(cNode.Nodes, pInfo.GetValue(component), pInfo.Name);
            }

            //不管是private的还是public的字段,只要挂了ShowInI就可以显示,某则一律隐藏
            foreach (FieldInfo fInfo in component.GetType().GetFields(flag))
            {
                ShowInInspector inspectorF = fInfo.GetCustomAttribute <ShowInInspector>();
                if (inspectorF != null)
                {
                    var obj = fInfo.GetValue(component);
                    if (obj != null)
                    {
                        AddNode(cNode.Nodes, fInfo.GetValue(component), fInfo.Name);
                    }
                }
            }
            return(cNode);
        }
Ejemplo n.º 2
0
        private TreeNode AddGameObjectNode(TreeNodeCollection rootNode, GameObject gameObject)
        {
            TreeNode oNode = AddNode(rootNode, "GameObject", "GameObject:" + gameObject.Name);

            if (!gameObject.IsActive)
            {
                oNode.ForeColor = System.Drawing.Color.Gray;
            }
            else
            {
                oNode.ForeColor = System.Drawing.Color.Orange;
            }

            //属性默认显示
            BindingFlags flag = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;

            foreach (PropertyInfo pInfo in gameObject.GetType().GetProperties(flag))
            {
                HideInInspector inspectorF = pInfo.GetCustomAttribute <HideInInspector>();
                if (inspectorF != null)
                {
                    continue;
                }
                AddNode(oNode.Nodes, pInfo.GetValue(gameObject), pInfo.Name);
            }

            //不管是private的还是public的字段,只要挂了ShowInI就可以显示,某则一律隐藏
            foreach (FieldInfo fInfo in gameObject.GetType().GetFields(flag))
            {
                ShowInInspector inspectorF = fInfo.GetCustomAttribute <ShowInInspector>();
                if (inspectorF != null)
                {
                    var obj = fInfo.GetValue(gameObject);
                    if (obj != null)
                    {
                        AddNode(oNode.Nodes, fInfo.GetValue(gameObject), fInfo.Name);
                    }
                }
            }

            return(oNode);
        }