private bool HandleHideInInspectorAttribute(FieldInfo properyfield, object obj) { HideInInspector HideAttribute = properyfield.GetCustomAttribute <HideInInspector>(); if (HideAttribute != null) { return(false); } return(true); }
private void DrawClassPublicFields(System.Type actionType, object actionInstance) { if (_fieldStyle == null) { _fieldStyle = new GUIStyle(EditorStyles.label); _fieldStyle.normal.textColor = Color.white; _fieldStyle.fontSize = 10; _fieldStyle.fontStyle = FontStyle.Normal; _fieldStyle.alignment = TextAnchor.MiddleLeft; } if (actionInstance != null) { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.LabelField($"{_currentEditInstance.name} #{actionInstance.GetHashCode ()}"); EditorGUI.EndDisabledGroup(); } if (_currentEditInstance.publicFields == null) { return; } FieldInfo[] publicFields = _currentEditInstance.publicFields; foreach (FieldInfo field in publicFields) { Type type = field.FieldType; // string title = GetAttribute<TitleAttribute>(field)?.Text; // // if (title == null) // title = field.Name; HideInInspector hideAttr = GetAttribute <HideInInspector> (field); // if (hideAttr != null) { continue; } object fieldValue = GUIForFieldTypes(field.Name, field, actionInstance); // 提交字段值改动 if (fieldValue != field.GetValue(actionInstance)) { field.SetValue(actionInstance, fieldValue); } } }
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); }
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); }
private static bool ShouldDisplay(FieldInfo fieldInfo, object targetObject) { Type targetType = targetObject.GetType(); HideInInspector hideInInspector = GetAttribute <HideInInspector>(fieldInfo); if (hideInInspector != null) { return(false); } DisplayConditionAttribute displayCondition = GetAttribute <DisplayConditionAttribute>(fieldInfo); if (displayCondition != null) { MethodInfo checkingFunction = targetType.GetMethod(displayCondition.CheckingFunction); return((bool)checkingFunction.Invoke( targetObject, new object[] { })); } return(true); }
public static bool IsHideInInspector(FieldInfo fieldInfo) { HideInInspector attribute = AttributeHelper.GetAttribute <HideInInspector>(fieldInfo); return(attribute != null); }
static public bool IsHidden(FieldInfo p_fieldInfo) { HideInInspector hideInInspectorAttribute = p_fieldInfo.GetCustomAttribute <HideInInspector>(); return(hideInInspectorAttribute != null); }