Ejemplo n.º 1
0
        protected override void DrawField(IToggledAttribute dynamicHide, Rect position, SerializedProperty property, GUIContent label)
        {
            ToggledFloatAttribute dynamicFloat = (ToggledFloatAttribute)dynamicHide;

            if (dynamicFloat.slider)
            {
                EditorGUI.Slider(position, property, dynamicFloat.min, dynamicFloat.max, label);
            }
            else
            {
                EditorGUI.PropertyField(position, property, label, true);
            }
        }
Ejemplo n.º 2
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            IToggledAttribute dynamicHide = (IToggledAttribute)attribute;
            bool enabled = GetEnabled(dynamicHide, property);

            if (enabled)
            {
                return(EditorGUI.GetPropertyHeight(property, label));
            }
            else
            {
                return(-EditorGUIUtility.standardVerticalSpacing);
            }
        }
Ejemplo n.º 3
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            IToggledAttribute dynamicHide = (IToggledAttribute)attribute;
            bool enabled = GetEnabled(dynamicHide, property);

            bool wasEnabled = GUI.enabled;

            GUI.enabled = enabled;
            if (enabled)
            {
                DrawField(dynamicHide, position, property, label);
            }

            GUI.enabled = wasEnabled;
        }
Ejemplo n.º 4
0
        private bool GetEnabled(IToggledAttribute dynamicHide, SerializedProperty property)
        {
            bool               enabled             = true;
            string             propertyPath        = property.propertyPath;
            string             conditionPath       = propertyPath.Replace(property.name, dynamicHide.Controller);
            SerializedProperty sourcePropertyValue = property.serializedObject.FindProperty(conditionPath);

            if (sourcePropertyValue != null)
            {
                if (dynamicHide.Type == ControlType.Integer)
                {
                    enabled = sourcePropertyValue.intValue == dynamicHide.Condition;
                }
                else if (dynamicHide.Type == ControlType.Boolean)
                {
                    enabled = sourcePropertyValue.boolValue;
                }
            }

            return(enabled);
        }
Ejemplo n.º 5
0
 protected override void DrawField(IToggledAttribute dynamicHide, Rect position, SerializedProperty property, GUIContent label)
 {
     EditorGUI.PropertyField(position, property, label, true);
 }
Ejemplo n.º 6
0
 abstract protected void DrawField(IToggledAttribute dynamicHide, Rect position, SerializedProperty property, GUIContent label);