Esempio n. 1
0
        public static bool IsConditionMatch(UnityEngine.Object owner, ConditionalData condition)
        {
            if (!condition.IsSet)
            {
                return(true);
            }

            var so = new SerializedObject(owner);

            foreach (var fieldCondition in condition)
            {
                if (fieldCondition.Field.IsNullOrEmpty())
                {
                    continue;
                }

                var property = so.FindProperty(fieldCondition.Field);
                if (property == null)
                {
                    LogFieldNotFound(so.targetObject, fieldCondition.Field);
                }

                bool passed = IsConditionMatch(property, fieldCondition.Inverse, fieldCondition.CompareAgainst);
                if (!passed)
                {
                    return(false);
                }
            }

            return(condition.IsMethodConditionMatch(owner));
        }
Esempio n. 2
0
        public static bool IsPropertyConditionMatch(SerializedProperty property, ConditionalData condition)
        {
            if (!condition.IsSet)
            {
                return(true);
            }

            foreach (var fieldCondition in condition)
            {
                var relativeProperty = FindRelativeProperty(property, fieldCondition.Field);
                if (relativeProperty == null)
                {
                    LogFieldNotFound(property, fieldCondition.Field);
                }

                bool passed = IsConditionMatch(relativeProperty, fieldCondition.Inverse, fieldCondition.CompareAgainst);
                if (!passed)
                {
                    return(false);
                }
            }

            return(condition.IsMethodConditionMatch(property.GetParent()));
        }