public static PropertyDrawer Create([NotNull] LinkedMemberInfo memberInfo, [CanBeNull] IParentDrawer parent, [CanBeNull] GUIContent label, bool readOnly, [CanBeNull] string getterErrorOrWarning, LogType getterErrorOrWarningType) { PropertyDrawer result; if (!DrawerPool.TryGet(out result)) { result = new PropertyDrawer(); } if (!string.IsNullOrEmpty(getterErrorOrWarning)) { result.OnErrorOrWarningWhenCallingGetter(getterErrorOrWarning, getterErrorOrWarningType); } object useValue = memberInfo.Type.IsValueType ? memberInfo.DefaultValue() : null; result.Setup(useValue, memberInfo.Type, memberInfo, parent, label, readOnly); result.LateSetup(); return(result); }
public static PropertyDrawer Create([NotNull] LinkedMemberInfo memberInfo, [CanBeNull] IParentDrawer parent, [CanBeNull] GUIContent label, bool readOnly) { PropertyDrawer result; if (!DrawerPool.TryGet(out result)) { result = new PropertyDrawer(); } object useValue; #if GET_VALUE_DURING_SETUP // call the getter of a property here, even though it could have side effects? // UPDATE: This results in errors if the property has index parameters! if (memberInfo.CanRead && (memberInfo.MemberInfo as PropertyInfo).GetIndexParameters().Length == 0) { try { useValue = memberInfo.GetValue(0); } catch (Exception e) { Debug.LogError(e); useValue = memberInfo.DefaultValue(); } } else #endif { useValue = memberInfo.DefaultValue(); } result.Setup(useValue, memberInfo.Type, memberInfo, parent, label, readOnly); result.LateSetup(); return(result); }