Class RuleCreatorAttribute
This attribute is used to tag methods that associate IComponentRuleCreator instances with component types. Unity automatically tracks the registered component types in the opened scenes, when a component has the same type (or is a derived class) the associated CreateRules(Component, List<BuildValidationRule>) instance method is invoked.
Inherited Members
Namespace: UnityEditor.PolySpatial.Validation
Syntax
[AttributeUsage(AttributeTargets.Method)]
public class RuleCreatorAttribute : Attribute, _Attribute
Remarks
The tagged method should have the following signature:
<code>static void Method(List<ValueTuple<Type, IComponentRuleCreator>> ruleCreators)</code>
The rule creators are registered in the same order as they are added in the
ruleCreators
list parameter.
It's possible to associate a component type with a null IComponentRuleCreator,
in this case no validation will be performed for the component type. This is useful to override validations for
derived types.
Examples
public class MyInvalidComponent : MonoBehaviour
{ }
public class MyValidDerivedComponent : MyInvalidComponent
{ }
public class MyRuleCreatorManager
{
[RuleCreatorAttribute]
public static void RegisterRuleCreators(List<ValueTuple<Type, IComponentRuleCreator>> ruleCreators)
{
// no validation will be performed for MyValidDerivedComponent
ruleCreators.Add(new(typeof(MyValidDerivedComponent), null));
ruleCreators.Add(new(typeof(MyInvalidComponent), new UnsupportedComponentsRule(PolySpatialSceneType.Volume, PolySpatialSceneType.MR, PolySpatialSceneType.VR)));
}
}
Constructors
RuleCreatorAttribute(Int32)
The attribute constructor.
Declaration
public RuleCreatorAttribute(int priority = 0)
Parameters
Type | Name | Description |
---|---|---|
Int32 | priority | An optional priority value to define the order to register the rule creators. High values are registered later, the default value is .
|