コード例 #1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            MMFConditionAttribute conditionAttribute = (MMFConditionAttribute)attribute;
            bool enabled           = GetConditionAttributeResult(conditionAttribute, property);
            bool previouslyEnabled = GUI.enabled;

            GUI.enabled = enabled;
            if (!conditionAttribute.Hidden || enabled)
            {
                EditorGUI.PropertyField(position, property, label, true);
            }
            GUI.enabled = previouslyEnabled;
        }
コード例 #2
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            MMFConditionAttribute conditionAttribute = (MMFConditionAttribute)attribute;
            bool enabled = GetConditionAttributeResult(conditionAttribute, property);

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

            if (sourcePropertyValue != null)
            {
                enabled = sourcePropertyValue.boolValue;
            }
            else
            {
                Debug.LogWarning("No matching boolean found for ConditionAttribute in object: " + condHAtt.ConditionBoolean);
            }

            return(enabled);
        }
コード例 #4
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            MMFConditionAttribute conditionAttribute = (MMFConditionAttribute)attribute;
            bool enabled = GetConditionAttributeResult(conditionAttribute, property);

            if (!conditionAttribute.Hidden || enabled)
            {
                return(EditorGUI.GetPropertyHeight(property, label));
            }
            else
            {
                int multiplier = 1; // this multiplier fixes issues in differing property spacing between MMFeedbacks and MMF_Player
                if (property.depth > 0)
                {
                    multiplier = property.depth;
                }
                return(-EditorGUIUtility.standardVerticalSpacing * multiplier);
            }
        }