Esempio n. 1
0
        /// <summary>
        /// 处理实体组件
        /// </summary>
        private static List <EntityComView> HandleEntityComs(Entity entity)
        {
            List <EntityComView> comViews = new List <EntityComView>();
            //组件名
            HashSet <string> entityComs = entity.GetAllComStr();

            foreach (string comName in entityComs)
            {
                BaseCom     com    = entity.GetCom(comName);
                FieldInfo[] fields = LCReflect.GetTypeFieldInfos(com.GetType());

                EntityComView comView = new EntityComView(comName, fields, com);

                comViews.Add(comView);
            }

            return(comViews);
        }
Esempio n. 2
0
        /// <summary>
        /// 渲染实体组件列表
        /// </summary>
        private static void DrawEntityComs(bool isShow, List <EntityComView> comViews, float width, float height)
        {
            if (isShow == false)
            {
                return;
            }
            EDLayout.CreateScrollView(ref ScrollPos, "GroupBox", width, height, () =>
            {
                for (int i = 0; i < comViews.Count; i++)
                {
                    EntityComView comView = comViews[i];
                    EditorGUILayout.Space();
                    GUI.color = Color.green;
                    //组件名
                    EditorGUILayout.LabelField("组件:", comView.ComName, GUILayout.Width(width), GUILayout.Height(20));

                    //可编辑键值
                    for (int j = 0; j < comView.EditorValueList.Count; j++)
                    {
                        GUI.color            = Color.red;
                        ComKeyValueView info = comView.EditorValueList[j];
                        object valueObj      = info.Info.GetValue(info.Com);
                        EDTypeField.CreateTypeField(info.KeyName + "= ", ref valueObj, info.Info.FieldType, width, 20);
                        LCReflect.SetTypeFieldValue(info.Com, info.KeyName, valueObj);
                    }

                    //只读值
                    for (int j = 0; j < comView.ValueList.Count; j++)
                    {
                        GUI.color            = Color.white;
                        ComKeyValueView info = comView.ValueList[j];
                        object valueObj      = info.Info.GetValue(info.Com);
                        EDTypeField.CreateLableField(info.KeyName + "= ", valueObj.ToString(), width, 20);
                    }
                }
            });
        }