コード例 #1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            IntConditionAttribute condHAtt = (IntConditionAttribute)attribute;
            bool enabled = IsShow(condHAtt, property);

            if (enabled)
            {
                EditorGUI.PropertyField(position, property, label, true);
            }
        }
コード例 #2
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            IntConditionAttribute condHAtt = (IntConditionAttribute)attribute;

            if (IsShow(condHAtt, property))
            {
                return(EditorGUI.GetPropertyHeight(property, label));
            }
            else
            {
                return(-EditorGUIUtility.standardVerticalSpacing);
            }
        }
コード例 #3
0
        private bool IsShow(IntConditionAttribute conditionAttribute, SerializedProperty property)
        {
            bool               enabled             = true;
            string             propertyPath        = property.propertyPath;
            string             conditionPath       = propertyPath.Replace(property.name, conditionAttribute.intField);
            SerializedProperty sourcePropertyValue = property.serializedObject.FindProperty(conditionPath);

            if (sourcePropertyValue != null)
            {
                enabled = sourcePropertyValue.intValue == conditionAttribute.expertValue;
            }
            else
            {
                Debug.LogWarning("Attempting to use a ConditionAttribute but no matching SourcePropertyValue found in object: " + conditionAttribute.intField);
            }
            return(enabled);
        }