public EntityComView(string comName, FieldInfo[] fieldInfos, BaseCom baseCom) { ComName = comName; ComAttribute comAttribute = LCReflect.GetTypeAttr <ComAttribute>(baseCom.GetType()); if (comAttribute != null) { ComName = comAttribute.ViewName; } for (int i = 0; i < fieldInfos.Length; i++) { FieldInfo info = fieldInfos[i]; ComKeyValueView keyValue = new ComKeyValueView(info.Name, info, baseCom); ComValueAttribute comValueAttribute = LCReflect.GetFieldAttr <ComValueAttribute>(info); if (comValueAttribute != null) { if (comValueAttribute.ViewEditor) { EditorValueList.Add(keyValue); } else { if (comValueAttribute.ShowView) { ValueList.Add(keyValue); } } } } }
/// <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); } } }); }