Simplified Rule

We noticed that most of the rules people are adding does not have a resolution, and only have an error message as Inspector UI, this is the reason why SV_SimplifiedRule abstract class was created. To allow you to write less code and save some time while making rules.

Here is a default rule example that will check if SpriteRenderer and Image components are attached to the same game object.

using UnityEngine;
using UnityEngine.UI;
using SA.Productivity.SceneValidator;
...

public class SV_SpriteRendererCompatibilityRule : SV_SimplifiedRule<SpriteRenderer>
{
    public override string GetErrorMessage(SpriteRenderer component, SV_ValidationState state) {
        return "SpriteRenderer can't be located on the same Gameobject with an Image component";
    }

    public override SV_ValidationState OnValidate(SpriteRenderer component) {
        var go = component.gameObject;
        if(go.GetComponent<Image>() != null) {
            return SV_ValidationState.Error;
        } else {
            return SV_ValidationState.Ok;
        }
    }
}