コード例 #1
0
        bool Validate(SerializedProperty property)
        {
            if (attribute.validator == null)
            {
                return(true);
            }

            SerializedProperty prop = property.serializedObject.FindProperty(attribute.propertyPath);

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

            bool valid = true;

            try
            {
                valid = attribute.validator(prop);
            }
            catch (Exception)
            {
                Dbg.LogErrorOnce(
                    Dbg.Context(attribute),
                    "ValueRestrictAttribute validator for {0}.{1} threw. This message will only log once",
                    property.serializedObject, property.propertyPath
                    );
            }

            return(valid);
        }