Skip to content

Instantly share code, notes, and snippets.

@DashW
Created November 4, 2020 12:31
Show Gist options
  • Save DashW/98f8e1de9edd28af81d2306116749810 to your computer and use it in GitHub Desktop.
Save DashW/98f8e1de9edd28af81d2306116749810 to your computer and use it in GitHub Desktop.
Unreal EditorValidatorBase Python API extracted from unreal.py
class EditorValidatorBase(Object):
r"""
* The EditorValidatorBase is a class which verifies that an asset meets a specific ruleset.
* It should be used when checking engine-level classes, as UObject::IsDataValid requires
* overriding the base class. You can create project-specific version of the validator base,
* with custom logging and enabled logic.
*
* C++ and Blueprint validators will be gathered on editor start, while python validators need
* to register themselves
**C++ Source:**
- **Plugin**: DataValidation
- **Module**: DataValidation
- **File**: EditorValidatorBase.h
**Editor Properties:** (see get_editor_property/set_editor_property)
- ``is_enabled`` (bool): [Read-Write] Is Enabled
"""
def validate_loaded_asset(self, asset, validation_errors):
r"""
x.validate_loaded_asset(asset, validation_errors) -> (DataValidationResult, validation_errors=Array(Text))
Validate Loaded Asset
Args:
asset (Object):
validation_errors (Array(Text)):
Returns:
Array(Text):
validation_errors (Array(Text)):
"""
return (DataValidationResult.INVALID, Array.cast(Text, []))
def get_validation_result(self):
r"""
x.get_validation_result() -> DataValidationResult
Get Validation Result
Returns:
DataValidationResult:
"""
return DataValidationResult.INVALID
def can_validate_asset(self, asset):
r"""
x.can_validate_asset(asset) -> bool
Override this to determine whether or not you can validate a given asset with this validator
Args:
asset (Object):
Returns:
bool:
"""
return False
def asset_passes(self, asset):
r"""
x.asset_passes(asset) -> None
Asset Passes
Args:
asset (Object):
"""
return None
def asset_fails(self, asset, message, validation_errors):
r"""
x.asset_fails(asset, message, validation_errors) -> Array(Text)
Asset Fails
Args:
asset (Object):
message (Text):
validation_errors (Array(Text)):
Returns:
Array(Text):
validation_errors (Array(Text)):
"""
return Array.cast(Text, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment