Esempio n. 1
0
        public static bool IsVisible(SerializedProperty property)
        {
            ShowIfAttributeBase showIfAttribute = GetAttribute <ShowIfAttributeBase>(property);

            if (showIfAttribute == null)
            {
                return(true);
            }

            object target = GetTargetObjectWithProperty(property);

            List <bool> conditionValues = GetConditionValues(target, showIfAttribute.Conditions);

            if (conditionValues.Count > 0)
            {
                bool enabled = GetConditionsFlag(conditionValues, showIfAttribute.ConditionOperator, showIfAttribute.Inverted);
                return(enabled);
            }
            else
            {
                string message = showIfAttribute.GetType().Name + " needs a valid boolean condition field, property or method name to work";
                Debug.LogWarning(message, property.serializedObject.targetObject);

                return(false);
            }
        }
Esempio n. 2
0
        public static bool IsVisible(Object target, MethodInfo method)
        {
            ShowIfAttributeBase showIfAttribute = method.GetCustomAttribute <ShowIfAttributeBase>();

            if (showIfAttribute == null)
            {
                return(true);
            }

            List <bool> conditionValues = PropertyUtility.GetConditionValues(target, showIfAttribute.Conditions);

            if (conditionValues.Count > 0)
            {
                bool enabled = PropertyUtility.GetConditionsFlag(conditionValues, showIfAttribute.ConditionOperator, showIfAttribute.Inverted);
                return(enabled);
            }
            else
            {
                string message = showIfAttribute.GetType().Name + " needs a valid boolean condition field, property or method name to work";
                Debug.LogWarning(message, target);

                return(false);
            }
        }