public override void Begin(Rect position, SerializedProperty property, GUIContent label) { base.Begin(position, property, label); noFieldLabel = ((CustomAttributeBase)attribute).NoFieldLabel; noPrefixLabel = ((CustomAttributeBase)attribute).NoPrefixLabel; noIndex = ((CustomAttributeBase)attribute).NoIndex; prefixLabel = ((CustomAttributeBase)attribute).PrefixLabel; disableOnPlay = ((CustomAttributeBase)attribute).DisableOnPlay; disableOnStop = ((CustomAttributeBase)attribute).DisableOnStop; scrollbarThreshold = Screen.width - position.width > 19 ? 298 : 313; indentLevel = EditorGUI.indentLevel; currentEvent = Event.current; EditorGUI.BeginDisabledGroup((Application.isPlaying && disableOnPlay) || (!Application.isPlaying && disableOnStop)); if (fieldInfo.FieldType.IsArray) { index = AttributeUtility.GetIndexFromLabel(label); arrayProperty = property.GetParent(); if (noIndex) { if (string.IsNullOrEmpty(prefixLabel)) { label.text = label.text.Substring(0, label.text.Length - 2); } } else if (!string.IsNullOrEmpty(prefixLabel)) { prefixLabel += " " + index; } } if (drawPrefixLabel) { if (!noPrefixLabel) { if (!string.IsNullOrEmpty(prefixLabel)) { label.text = prefixLabel; } position = EditorGUI.PrefixLabel(position, label); } } else { if (noPrefixLabel) label.text = ""; else if (!string.IsNullOrEmpty(prefixLabel)) label.text = prefixLabel; } currentPosition = position; currentLabel = label; }
public override void Initialize(SerializedProperty property, GUIContent label) { base.Initialize(property, label); CustomAttributeBase customAttribute = (CustomAttributeBase)attribute; noFieldLabel = customAttribute.NoFieldLabel; noPrefixLabel = customAttribute.NoPrefixLabel; noIndex = customAttribute.NoIndex; prefixLabel = customAttribute.PrefixLabel; disableOnPlay = customAttribute.DisableOnPlay; disableOnStop = customAttribute.DisableOnStop; disableBool = customAttribute.DisableBool; indent = customAttribute.Indent; beforeSeparator = customAttribute.BeforeSeparator; afterSeparator = customAttribute.AfterSeparator; bool inverseBool = false; if (!string.IsNullOrEmpty(disableBool)) { inverseBool = disableBool.StartsWith("!"); string boolPath = property.GetParent().FindPropertyRelative(inverseBool ? disableBool.Substring(1) : disableBool).GetAdjustedPath(); boolDisabled = property.serializedObject.targetObject.GetValueFromMemberAtPath<bool>(boolPath); } boolDisabled = inverseBool ? !boolDisabled : boolDisabled; }
void InitializeParameters(SerializedProperty property, GUIContent label) { CustomAttributeBase customAttribute = (CustomAttributeBase)attribute; noFieldLabel = customAttribute.NoFieldLabel; noPrefixLabel = customAttribute.NoPrefixLabel; noIndex = customAttribute.NoIndex; prefixLabel = customAttribute.PrefixLabel; disableOnPlay = customAttribute.DisableOnPlay; disableOnStop = customAttribute.DisableOnStop; disableBool = customAttribute.DisableBool; indent = customAttribute.Indent; beforeSeparator = customAttribute.BeforeSeparator; afterSeparator = customAttribute.AfterSeparator; isArray = typeof(IList).IsAssignableFrom(fieldInfo.FieldType); if (isArray) { index = AttributeUtility.GetIndexFromLabel(label); arrayProperty = property.GetParent(); } bool inverseBool = !string.IsNullOrEmpty(disableBool) && disableBool.StartsWith("!"); boolDisabled = !string.IsNullOrEmpty(disableBool) && property.serializedObject.targetObject.GetValueFromMemberAtPath<bool>(inverseBool ? disableBool.Substring(1) : disableBool); boolDisabled = inverseBool ? !boolDisabled : boolDisabled; }
public virtual void Initialize(SerializedProperty property, GUIContent label) { _initialized = true; _isArray = typeof(IList).IsAssignableFrom(fieldInfo.FieldType); _lineHeight = EditorGUIUtility.singleLineHeight; if (_isArray) { _index = AttributeUtility.GetIndexFromLabel(label); _arrayProperty = property.GetParent(); } }