Sample Context Rule

In order to make own scene context validation rule, you need to implement SV_iContextValidationRule interface. The SV_ContextValidationRule abstract class is also provided to simplify the rule implementation. The example below will be based on SV_ContextValidationRule abstract class.

So let's say we want to make sure designer will get notified if he will overload our scene with a way too much particle systems. Let's say our limit is 3 ParticleSystem instances per scene. So we want to raise a warning if a limit is exceeded, and critical warning if an allowed number is doubled.  

Let's make our validation rule class and name it SV_ParticleSystemsCountValidation.  We will also specify that we explicitly checking only ParticleSystem components. 

public class SV_ParticleSystemsCountValidation : SV_ContextValidationRule<ParticleSystem>

Now we need to override a few validation methods. 


Validation logic should be placed inside this method. Method result should be one of the SV_ValidationState enum value.

public enum SV_ValidationState

Here is how our validation method will look like:

public override SV_ValidationState OnValidate(Scene context, List<ParticleSystem> components) {
    if(components.Count <= PARTICLE_SYSTEMS_LIMIT) {
        return SV_ValidationState.Ok;

    if(components.Count >=  (PARTICLE_SYSTEMS_LIMIT * 2)) {
        return SV_ValidationState.Error;

    return SV_ValidationState.Warning;


We may place all the additional UI we want to show. The simplest what can we do is to display a message box with an additional explanation of what is wrong with the scene.

public override void OnInspectorGUI(Scene context, List<ParticleSystem> components) {
        var state = OnValidate(context, components);
    switch(state) {
        case SV_ValidationState.Warning:
            EditorGUILayout.HelpBox("Scene Particle system limit exceeded", MessageType.Warning);

        case SV_ValidationState.Error:
            EditorGUILayout.HelpBox("Scene Particle system limit exceeded more then 2 times! " +
                                    "FIX immediately!!", MessageType.Error);


Optionally we may provide an issues resolution logic. For our case we can't provide resolution since we can't control wich particle systems has to be removed, this decision is up to scene designer. So we will just return NoResolution. Our GetResolution OnResolve will look like this:

public override SV_ResolutionState GetResolution(Scene context, List<ParticleSystem> components) {
    return SV_ResolutionState.NoResolution;

public override void OnResolve(Scene context, List<ParticleSystem> components) {


Final Steps

You may also override the rule name, otherwise, rule name will be the same as rule class name.

public override string Name {
    get {
        return "Particle Systems limit exceeded";

You may find full SV_ParticleSystemsCountValidation.cs script inside the plugin Example folder 

Register a Rule 

There are 2 ways how you can register rule to be considered by scene validation plugin.

1. Using the Plugin Settings Window. Drag & Drop rule script inside the Custom Rules section.

Scene validation will be restarted once new rules are added, so you can immediately see the results. In our case all 

2. Using Scripting. You may add the SV_iAutoContextRegistredValidationRule to your validation rule. In this case, Validator will pick up the rule on next script reload. 

public class SV_ParticleSystemsCountValidation : SV_ContextValidationRule<ParticleSystem>, SV_iAutoContextRegistredValidationRule

One your case, this is what will happen after a rule is applied:

Important Notes

The rule you made will be instantiated once per scene. New rule instance isn't created each time validation is executed. Do not cache scene or components passed to one of the validation methods.