public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (property.isArray) { WarningsPool.LogCollectionsNotSupportedWarning(property, nameof(OverrideLabelAttribute)); } label.text = ((OverrideLabelAttribute)attribute).NewLabel; var customDrawer = CustomDrawerUtility.GetPropertyDrawerForProperty(property, fieldInfo, attribute); if (customDrawer != null) { customDrawer.OnGUI(position, property, label); } else { EditorGUI.PropertyField(position, property, label, true); } }
/// <summary> /// Get the other Property which is stored alongside with specified Property, by name /// </summary> private static SerializedProperty FindRelativeProperty(SerializedProperty property, string propertyName) { if (property.depth == 0) { return(property.serializedObject.FindProperty(propertyName)); } var path = property.propertyPath.Replace(".Array.data[", "["); var elements = path.Split('.'); var nestedProperty = NestedPropertyOrigin(property, elements); // if nested property is null = we hit an array property if (nestedProperty == null) { var cleanPath = path.Substring(0, path.IndexOf('[')); var arrayProp = property.serializedObject.FindProperty(cleanPath); WarningsPool.LogCollectionsNotSupportedWarning(arrayProp, nameof(ConditionalFieldAttribute)); return(null); } return(nestedProperty.FindPropertyRelative(propertyName)); }