The Better Validation package provides attributes to perform validation in scenes and the whole project. Link to the project:
https://github.com/techno-dwarf-works/better-validation
Validation
To initiate validation, you can go to Toolbar > Better > Validation > Open Validation Window
, or it may start automatically prior to building (validation before play mode will be available in the future).
Settings
If you wish to disable automatic pre-build validation or change the logging level, you can open the settings at Toolbar > Better > Validation > Highlight settings
or Edit > Project Settings > Better > Validation
.
Available Attributes
The available attributes completely cover all the needs of the modern development process. But if you need more, just add an issue on GitHub, and I'll get back to you.
NotNull: Fails if a
UnityEngine.Object
is null or has a missing reference.PrefabField: Inherits from NotNull and fails if the field references a scene object or an object context.
SceneReference: Inherits from NotNull and fails if the field references a prefab in the Project.
-
Find: Searches for a Component of Type provider in the constructor. It has additional settings:
- ValidateIfFieldEmpty: Configures the search only if the field is null or missing.
- RequireDirection: Configures the direction of the search.
-
DataValidation: Validates data in the field using the provided method name. It only supports methods in the same class. The method can return one of the following types:
-
void
: Validation will be called, but nothing will be displayed in the editor or the Validation Window. -
bool
:true
represents a successful validation, whilefalse
will draw a default error in the editor and the Validation Window. -
string
: The returned string is regarded as a failed validation, while an empty string indicates success.
-
All attributes have a ValidationType
that represents the importance of the validation result.
The plugin supports extensions through IBuildValidationStep and IValidationStep interfaces.
Top comments (0)