private void DrawCom(BaseCom baseCom) { if (!ContextDataCache.TryGetContextData <GUIStyle>("BigLabel", out var bigLabel)) { bigLabel.value = new GUIStyle(GUI.skin.label); bigLabel.value.fontSize = 18; bigLabel.value.fontStyle = FontStyle.Bold; bigLabel.value.alignment = TextAnchor.MiddleLeft; bigLabel.value.stretchWidth = true; } List <FieldInfo> serFields = new List <FieldInfo>(); List <FieldInfo> noSerFields = new List <FieldInfo>(); foreach (var item in ReflectionHelper.GetFieldInfos(baseCom.GetType())) { bool ignore = false; foreach (var ignoreName in IgnoreFieldName) { if (item.Name.Contains(ignoreName)) { ignore = true; continue; } } if (ignore) { continue; } if (AttributeHelper.TryGetFieldAttribute(item, out NonSerializedAttribute attr)) { noSerFields.Add(item); } else { serFields.Add(item); } } _serFoldout = EditorGUILayout.Foldout(_serFoldout, "Serialized:"); if (_serFoldout) { foreach (var item in serFields) { object newValue = GUILayoutExtension.DrawField(item.FieldType, item.GetValue(baseCom), GraphProcessorEditorUtility.GetDisplayName(item.Name), ""); if (newValue == null || !newValue.Equals(item.GetValue(baseCom))) { item.SetValue(baseCom, newValue); } } } _noSerFoldout = EditorGUILayout.Foldout(_noSerFoldout, "NoSerialized:"); if (_noSerFoldout) { EditorGUI.BeginDisabledGroup(true); foreach (var item in noSerFields) { GUILayoutExtension.DrawField(item.FieldType, item.GetValue(baseCom), GraphProcessorEditorUtility.GetDisplayName(item.Name), ""); } EditorGUI.EndDisabledGroup(); } }
public static bool TryGetContextData <T>(string _key, out ContextData <T> _contextData) { return(ContextDatas.TryGetContextData(_key, out _contextData)); }