private static bool IsBindingRequiredOnField(System.Reflection.FieldInfo fieldInfo) { object[] bindingTypes = fieldInfo.GetCustomAttributes(typeof(SOBindingType), false); for (int bindingTypesIndex = 0; bindingTypesIndex < bindingTypes.Length; ++bindingTypesIndex) { SOBindingType bindingType = bindingTypes[bindingTypesIndex] as SOBindingType; if (bindingType.Binding == SO.BindingType.Required) { return(true); } } return(false); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { SOBindingType bindingType = attribute as SOBindingType; Color c = GUI.color; if (bindingType.Binding == SO.BindingType.Required && property.propertyType == SerializedPropertyType.ObjectReference && property.objectReferenceValue == null) { GUI.color = Color.red; } EditorGUI.PropertyField(position, property, label, true); GUI.color = c; }