private void HandleProperty(SerializedProperty prop) { if (prop.name.Equals("m_Script")) { return; } var disabledAttribute = UTUtils.GetPropertyAttribute <DisabledAttribute>(prop); propDisabled = false; if (disabledAttribute != null) { if (disabledAttribute.methodName != null) { propDisabled = UTUtils.GetVisibleThroughAttribute(prop, disabledAttribute.methodName, false); } else { propDisabled = true; } } if (prop.isArray && prop.propertyType != SerializedPropertyType.String) { HandleArray(prop); } else { EditorGUI.BeginChangeCheck(); EditorGUI.BeginDisabledGroup(propDisabled); EditorGUILayout.PropertyField(prop); EditorGUI.EndDisabledGroup(); if (!EditorGUI.EndChangeCheck()) { return; } var changeCallback = UTUtils.GetPropertyAttribute <OnValueChangedAttribute>(prop); if (changeCallback == null) { return; } var m = prop.serializedObject.targetObject.GetType().GetMethod(changeCallback.methodName, UTUtils.flags); if (m == null) { return; } if (m.GetParameters().Length > 1) { m.Invoke( serializedObject.targetObject, new object[] { serializedObject, prop }); } else { m.Invoke( serializedObject.targetObject, new object[] { prop }); } } propDisabled = false; }
private void RenderHelpBox(SerializedProperty prop) { var helpBoxAttr = UTUtils.GetPropertyAttribute <HelpBoxAttribute>(prop); if (helpBoxAttr != null) { if (helpBoxAttr.methodName.Length > 0 && !UTUtils.GetVisibleThroughAttribute(prop, helpBoxAttr.methodName, false)) { return; } UTStyles.RenderNote(helpBoxAttr.text); } }
public override void AfterGUI(SerializedProperty property) { if (methodName != "") { isVisible = UTUtils.GetVisibleThroughAttribute(property, methodName, false); } if (!isVisible) { return; } UTStyles.RenderNote(text); }
public override bool BeforeGUI(ref Rect position, SerializedProperty property, GUIContent label, bool visible) { isVisible = visible; if (!visible) { return(false); } if (methodName != "") { isVisible = UTUtils.GetVisibleThroughAttribute(property, methodName, false); } if (isVisible && property.name != "data" && property.depth == 0) { position.yMax -= boxHeight; } return(true); }
private void HandleArray(SerializedProperty prop) { var attrs = UTUtils.GetPropertyAttributes(prop); var modifierAttrs = UTUtils.GetPropertyAttributes <Attribute>(prop); var isGroup = attrs.Where(a => a is ListViewAttribute).ToArray().Length > 0; var groupAttribute = attrs.Select(a => a as ListViewAttribute).ToArray(); var onValueChangedAttribute = UTUtils.GetPropertyAttribute <OnValueChangedAttribute>(prop); // hideIf attribute var hideIfAttribute = modifierAttrs.OfType <HideIfAttribute>().ToArray(); var isHidden = hideIfAttribute.Length > 0 && UTUtils.GetVisibleThroughAttribute(prop, hideIfAttribute[0].methodName, false); // handling for regular arrays, make nicer down the line if (!isGroup) { if (isHidden) { return; } RenderArray(prop, onValueChangedAttribute?.methodName); if (droppedObjects) { return; } RenderHelpBox(prop); return; } var groupName = groupAttribute[0].name; var items = cT.GetFields().Where(f => f.GetAttribute <ListViewAttribute>() != null && f.GetAttribute <ListViewAttribute>().name == groupName) .ToList(); // fast exit on 1 element with list view if (items.Count < 2) { if (isHidden) { return; } RenderArray(prop, onValueChangedAttribute?.methodName); if (droppedObjects) { return; } RenderHelpBox(prop); return; } var index = items.FindIndex(a => a.Name == prop.name); if (index > 0) { return; } var sectionHeaderAttribute = UTUtils.GetPropertyAttribute <SectionHeaderAttribute>(prop); if (sectionHeaderAttribute != null) { UTStyles.RenderSectionHeader(sectionHeaderAttribute.text); } if (isHidden) { return; } var otherProp = serializedObject.FindProperty(items[1].Name); var leftPopupAttribute = UTUtils.GetPropertyAttribute <PopupAttribute>(prop); var rightPopupAttribute = UTUtils.GetPropertyAttribute <PopupAttribute>(otherProp); if (rightPopupAttribute != null || leftPopupAttribute != null) { RenderStackedArray(groupAttribute[0].name, prop, otherProp, leftPopupAttribute, rightPopupAttribute, groupAttribute[0].addMethodName, groupAttribute[0].addButtonText, onValueChangedAttribute?.methodName); if (droppedObjects) { return; } RenderHelpBox(prop); return; } RenderStackedArray(groupAttribute[0].name, prop, otherProp, groupAttribute[0].addMethodName, groupAttribute[0].addButtonText, onValueChangedAttribute?.methodName); if (droppedObjects) { return; } RenderHelpBox(prop); }
public override bool BeforeGUI(ref Rect position, SerializedProperty property, GUIContent label, bool visible) { isVisible = UTUtils.GetVisibleThroughAttribute(property, methodName, true); return(isVisible); }
public override bool GetVisible(SerializedProperty property) { isVisible = UTUtils.GetVisibleThroughAttribute(property, methodName, true); return(isVisible); }