Table of Contents

Method Constrain

Namespace
Gamelogic.Extensions
Assembly
Gamelogic.Extensions.dll

Constrain(SerializedProperty)

Constrains a given value to be valid (i.e. pass IsValid(SerializedProperty)).

protected virtual void Constrain(SerializedProperty property)

Parameters

property SerializedProperty

Remarks

If the given value is valid, it is simply returned. Otherwise, it is converted in some way to a valid value. For example, if the validation checks whether numeric values is in range, this method should return the value clamped to the range.

The result of this method should return true when passed to IsValid(SerializedProperty).

If there is not a reasonable way to get a valid value from a general value, it is better to leave this method unimplemented (but then this attribute should not have ForceValue set to true, otherwise an exception will be thrown when this method is called).

This method should only change the values of the types supported by the attribute.

This method is only available in the editor, and therefor subclasses should shield their implementations accordingly.