示例#1
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            var visibilityConditions = VisibilityCondition.ParseFromString(ConditionalAttribute.visibleConditions);

            var isVisible = VisibilityCondition.CheckConditions(visibilityConditions, property);

            // If the target field passes the check or we're just disabling the field - return the actual height
            if (isVisible)
            {
                return(EditorGUI.GetPropertyHeight(property, label));
            }

            // Invisible property; Remove the default spacing
            return(-EditorGUIUtility.standardVerticalSpacing);
        }
示例#2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var visibilityConditions = VisibilityCondition.ParseFromString(ConditionalAttribute.visibleConditions);
            var enabledConditions    = VisibilityCondition.ParseFromString(ConditionalAttribute.enableConditions);

            var isVisible = VisibilityCondition.CheckConditions(visibilityConditions, property);
            var isEnabled = VisibilityCondition.CheckConditions(enabledConditions, property);

            var guiEnabled = GUI.enabled;

            GUI.enabled = isEnabled;

            if (isVisible)
            {
                EditorGUI.PropertyField(position, property, label, true);
            }

            GUI.enabled = guiEnabled;
        }
示例#3
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            foreach (var conditionalLabel in ConditionalAttribute.conditionalLabels)
            {
                var conditions = VisibilityCondition.ParseFromString(conditionalLabel.Value);

                var isVisible = VisibilityCondition.CheckConditions(conditions, property);

                if (!isVisible)
                {
                    continue;
                }

                label.text = conditionalLabel.Key;
                break;
            }

            EditorGUI.PropertyField(position, property, label);
        }