コード例 #1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var att    = (EnabledIfAttribute)attribute;
            var parent = ReflectionTools.GetRelativeMemberParent(property.serializedObject.targetObject, property.propertyPath);
            var member = ReflectionTools.RTGetFieldOrProp(parent.GetType(), att.propertyName);
            var value  = (int)System.Convert.ChangeType(member.RTGetFieldOrPropValue(parent), typeof(int));

            enable      = value == att.value;
            GUI.enabled = enable;
            EditorGUI.PropertyField(position, property);
            GUI.enabled = true;
        }
コード例 #2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var att    = (EnabledIfAttribute)attribute;
            var parent = ReflectionTools.GetRelativeMemberParent(property.serializedObject.targetObject, property.propertyPath);
            var member = ReflectionTools.RTGetFieldOrProp(parent.GetType(), att.propertyName);

            if (member != null)
            {
                var objectValue = member.RTGetFieldOrPropValue(parent);
                var intValue    = 1;
                if (property.propertyType == SerializedPropertyType.ObjectReference)
                {
                    intValue = objectValue != null ? 1 : 0;
                }
                else
                {
                    intValue = (int)System.Convert.ChangeType(objectValue, typeof(int));
                }
                GUI.enabled = intValue == att.value;
            }
            EditorGUI.PropertyField(position, property);
            GUI.enabled = true;
        }