A brand new Odin Validator

Fix issues the moment they are introduced
3.1 BETA

Your personal project caretaker now in beta

Odin Validator has been rebuilt from the bottom up to be better, faster and leaner. It boasts new features such as live validation, project rules, sophisticated scanning and search filters, scene view widgets for issues, issue fixes, bulk issue fixing and more, all built around a philosophy of extensibility, configurability and customizability.

Everything is packed into one compact window, streamlined, centralized and easier to use than ever. The new Odin Validator is the ultimate companion for any team, small or large, making sure that you can move fast - without breaking things.


On-the-fly error detection

While you work, Odin Validator silently scans your project in the background, applying a vast, configurable set of rules, validations and filters all without interrupting work, and immediately notifying developers when issues relevant to their current work are detected. Validation is kept up to date as changes are made in the editor, assets are pulled from source control, and so on, making sure you always have the latest state of your project right at your fingertips.

New validation attributes

Odin already contains many validation attributes such as ChildGameObjectsOnly, Required, AssetsOnly, SceneObjectsOnly, ValidateInput and so on. We've added three additional built-in attributes to help boost productivity for your team.

[RequiredInPrefabAssets]
[DisallowPrefabModifications]
public string Name;

[RequiredInPrefabInstances]
public Camera Camera;

Fixes and bulk fixes

Validators which detect issues can choose to offer fixes for them. These provided fixes can range from things as simple as adding a missing Rigidbody or correcting a bad layer assignment, to complex operations requiring user input to resolve.

Fixes can be run individually, or run in bulk, where one fix is applied to several or all instances of a detected issue. No longer will you have to painstakingly trawl through your project looking for every single lost instance of an enemy prefab that you forgot needed a rigidbody, or even go through them one by one just to click a few buttons to resolve it manually. With bulk fixing, hours, days or sometimes even weeks of tedious work can be reduced to a single click of a button.

Simple and easy fix creation API

Creating a fix is both simple and fast, requiring an absolute minimum of boilerplate code and pointless tedium.


                [assembly: RegisterValidator(typeof(RockValidator))]

public class RockValidator : RootObjectValidator<Rock>
{
    protected override void Validate(ValidationResult result)
    {
        if (this.Object.GetComponent<Rigidbody>() == null)
        {
            result.AddError($"{this.Object.name} is missing a Rigidbody",
                Fix.Create("Add Rigidbody", () => this.Object.gameObject.AddComponent<Rigidbody>()));
        }
    }
}

Even easier with the new ISelfValidator interface

Instead of creating validation logic that needs to live in a separate file, editor only assembly or wrapped in clunky preprocessor statements, you can use the new ISelfValidator interface on any type in your project, such as your MonoBehaviours, ScriptableObjects, or even simple non-Unity object data types.

This handy new API gives you all the power of custom validators and fixes right inside the type that needs to be validated, with no fuss or boilerplate at all, making the process of adding custom validation and fixes as fast and effortless as it could possibly be.


public class MyComponent : MonoBehaviour, ISelfValidator
{
    public bool ShouldBeAboveSeaLevel;

    public void Validate(SelfValidationResult result)
    {
        if (this.ShouldBeAboveSeaLevel && this.transform.position.y < 0)
        {
            result.AddError(this.gameObject.name + " should be above sea level", SelfFix.Create(() =>
            {
                this.transform.position = new Vector3(this.transform.position.x, 0, this.transform.position.z);
            }));
        }
    }
}

Master your project

With a single click of a button, you can gain an overview of all issues in your entire project (or in only the parts you are interested in), and double-click any issues to instantly go to them. Improved scanning times yields results faster than ever before, and the option of background validation means your work will never be needlessly interrupted.

A new and improved validation issue overview boasts a vastly better user experience, with a large array of filters and search options, and the ability to smoothly scale to any size of project, displaying anything from a few dozen issues to many tens of thousands with buttery smooth performance.

Built-in Rules

Odin Validator now comes with several built-in, configurable rules, which can be enabled,
disabled and modified on both a team-wide project basis, or on a local machine-only basis.



Detect missing references

Detect broken assets

Detect duplicate components

Detect invalid layers

Detect shader compiler errors

Detect broken materials

Detect renderers with invalid materials

Detect invalid transform positions

Detect broken prefab connections

Detect use of obsolete components


And many, many more to come during the beta..



Create custom rules

Simply right-click anywhere in the project view or click the plus icon in the rules list to create
a custom rule from a script template. Serialized fields in the validator become configurable values.



[assembly: RegisterValidationRule(typeof(MyPhysicsMaterialValidator))]

public class MyPhysicsMaterialValidator : RootObjectValidator<Collider>
{
    // Objects in these layers must have a physics material assigned
    public LayerMask physicsMaterialLayers;

    protected override void Validate(ValidationResult result)
    {
        if (this.Object.sharedMaterial == null && (this.physicsMaterialLayers.value & (1 << this.Object.gameObject.layer)) != 0)
        {
            result.AddError($"{this.Object.name} needs a physics material");
        }
    }
}

Automated validation

Validate on play/build/startup

Exactly like the old validator, Odin Validator 3.1 provides event hooks that you can enable to scan your project a play, build or startup time and report with the results, optionally preventing the build from succeeding or stopping you from entering playmode with an invalid setup.

foreach (var result in ValidationSession.GlobalValidationSession.ValidateEverythingEnumerator(true, true, false, false))
{
    if (result.HighestSeverityResult.ResultType == ValidationResultType.Error)
    {
        Debug.LogError("Error: " + result.HighestSeverityResult.Message);
    }
    else if (result.HighestSeverityResult.ResultType == ValidationResultType.Warning)
    {
        Debug.LogError("Warning: " + result.HighestSeverityResult.Message);
    }
}

Validate in your custom pipeline/CI systems

Odin Validator's API is easy to use and invoke from your own code, anywhere you please. The full power and configurability of the validator is available through the API, to be run as part of your custom build pipeline, testing suite or CI systems.

Getting Started

Opening the Odin Validator

You can access the new validator from a couple of different places.

  • You can open the window from Tools > Odin Validator. This will open an editor for the global validation session.
  • The new Odin validator window can also be opened by clicking on the new scene widget. If multiple validation sessions are active, the scene widget can be right-clicked and from there you access individual validation sessions.
  • Right-click an asset or a folders and click on Asset folder or File > Odin Validator > Validate this to start a one-off validation session targeting only the selected assets or folders.

Configure the validator to your project

You can configure which parts of your project the validator should look at, such as which scenes should or shouldn't be validated. Use the include and exclude buttons highlighted in the image. You can add individual files or entire folders.

There are far more things that can be configured, but we’ll let you discover those while we write the documentation for the full release.

Quick start using attributes

Apply your attributes, set up your preferred rules, run a scan, and enjoy your new, faster and more reliable workflow.

public class MyComponent : MonoBehaviour
{
    [Required]
    public string Name;

    [AssetsOnly, AssetSelector, Required]
    public GameObject Prefab;

    [ChildGameObjectsOnly, Required]
    public GameObject Child;

    [ValidateInput("@OddNumber % 2 == 1", "@OddNumber + \" is too normal!\"")]
    public int OddNumber;
}

Migrating from the old validator

The new 3.1 Odin Validator can form a parallel install alongside the old version of the validator, so your old validation setup will not be affected during migration. During the beta, we will add an upgrade wizard, which will import as much of your prior validator setup as possible to the new validator.

Beta patch notes

Version 3.1.0.11 Beta

Odin Validator

Additions

  • Added ISelfValidator interface, which lets any type specify validation logic for itself which will be executed as part of validation as though a custom validator has been written for it.
  • Added ValidatorSeverity overload to ValidationResults, which registers an error or warning depending on the severity, and doesn't do anything if the severity is set to ignore.
  • Added MeshRendererValidator rule that detects missing materials, broken materials, and prefab modifications in mesh renderers.
  • Right clicking issues from scenes now presents a "Ping scene asset" option.
  • Added Debug mode in validator settings to hunt down bugs during bulk fixing and show additional information in issue info.

Fixes

  • Validation rules will now deserialize with default values for new fields that were added after the rule was last changed and saved.
  • Fixed Validator about page not rendering the Odin Validator logo.
  • Prevented "FormatException: Unrecognized Guid format" errors from occuring when assets was removed outside of Unity.
  • Fixed error where validators for SceneAsset and SceneValidators would come in conflict and wipe out each other's validation results in the validation overview whenever they were revalidated, such as when visible issues were being continuously validated.
  • Fixed layout error logs that would occur when running many fixes that added/removed components. There is a separate issue where layout errors still occur after running some kinds of fixes; we are still working on resolving those, but this should take care of most of them.

Odin Inspector

Fixes

  • Fixed Button attribute's DirtyOnClick still causing scenes and assets to be marked dirty when undoable changes are made. This means undo is now disabled for changes made by button clicks when DirtyOnClick is set to false.

Odin Serializer

Features

  • Integrated the Easy AOT feature which has been offered as an experimental testing build for a long time. This feature means Odin Serializer can function without AOT generation support in many cases where it would have failed before. This is a very large change to make which required major reworks and additions to the serializer, hence why it has been in testing for so long. As it has been reported stable and functioning, we've finally chosen to add it.

Fixes

  • EditorOnlyModyConfigUtility will now not throw exceptions when drawing the editor only mode warning for SerializedX classes in an editor only mode distribution of Odin.

Version 3.1.0.10 Beta

Odin Validator

See page above for information about changes and additions to the validator in 3.1. The validator has been rewritten from scratch in 3.1 and can form a parallel install with the pre-3.1 validator, so patch notes from the prior version would not make much sense.

Odin Inspector

Optimizations

  • Added lazy fetching of PrefabUtility.GetPropertyModifications for a PropertyTree's PrefabModificationHandler, so it is only fetched when it is requested on any given frame, as fetching it is very slow. More optimizations are coming to this, such that fetched modifications are only updated when they actually change, instead of every frame they are actually requested, which is still the case even with this change.
  • Attribute expressions are now cached for a time to prevent constant repeated parsing and compilation of the same expressions in cases such as validation scanning.
  • PrefabModificationHandler is now cached and reused properly when PropertyTree instances are cached and reused.
  • Drastically increased performance of validation and project scanning over prior versions of Odin. Changes made are too numerous to list exhaustively, and cover the entire codebase. We have seen 10-100x improvements in scan time, though scans of very large projects can still take a while. In most of our test cases, Unity's asset and scene loading accounts for the majority of the validation scan time.
  • EditorOnlyModeConfig now has far less of an impact on startup time. Where before it could take seconds, it will now in most cases take <3 milliseconds to initialize.

Additions

  • Added SdfIcons to Odin, a new class for drawing icons in the editor. These are a set of icons which are drawn using signed distance fields, meaning they scale to being drawn precisely at any resolution. Long term, these will replace the EditorIcons class. The SdfIcons class includes the entirety of the Bootstrap icon library. You can search and preview available icons using the new Tools > Odin Inspector > SDF Icon Overview window.
  • Added PlaceholderLabel attribute, which draws a placeholder label inside a text field while the text field is empty.
  • Added three new attributes: RequiredInPrefabAssets, DisallowPrefabModifications and RequiredInPrefabInstances.
  • Added EnumTypeUtilities and cleaned up EnumSelector.
  • Added leak detection for Odin PropertyTree instances, which will print a helpful message to the debug log when a PropertyTree is garbage collected without first having been disposed, and which contains information about where the tree was allocated to help track down the source of the leak.
  • Added MessagBox overload in SirenixEditorGUI that takes a GuiStyle.
  • Added MiniLabelCentered to SirenixGUIStyles.
  • Added PropertyTree.EnableLeakDetection setting.
  • Added RecordUndoForChanges to PropertyTree, that lets you specify whether or not the undo should be recorded.
  • Added Sirenix.OdinInspector.Editor.UndoTracker utility that can be used to track when objects are modified, as well as when those modifications are undone and redone on which objects.
  • Added UnityTypeCacheUtility.GetTypesWithAttribute proxy methods.
  • Added various OdinMenuTree colors to SirenixGuiStyles.
  • Added EditorPref<T> with subtypes EditorPrefBool, EditorPrefString, EditorPrefFloat, EditorPrefInt and EditorPrefEnum<T> as a convenient utility wrapper for values stored in editor prefs.
  • Added ProjectSetting<T> with subtypes ProjectSettingBool, ProjectSettingString, ProjectSettingFloat, ProjectSettingInt and ProjectSettingEnum<T> as a convenient utility for a value which can either be stored serialized in a project asset, or overwritten on a local machine basis by being stored in editor prefs. As such, this enables having settings values which can be adjusted in a project but also controlled on a per-machine basis with local user overrides for improved collaboration possibilities. Also added ProjectSettingKeyAttribute, and ProjectSettingsGlobalConfig<T> as a new GlobalConfig type which supports storing ProjectSetting values via ProjectSettingKey attributes set on the settings members.
  • Added .Slice() extension method to strings which is the same as .Slice(0).
  • Added TrimStart(), TrimEnd() and Trim() to StringSlice.

Improvements

  • GuiHelper.GetAssetThumbnail now gives more accurate thumbnail icons.

Fixes

  • Added bounds check to StringSlice's indexer.
  • CustomValueDrawer now also works for drawing methods and expressions that return void; in this case, no value will be set automatically.
  • Fixed a bug where OdinEditorWindow's without a scroll bar would not paint the background correctly.
  • Fixed bug where EnumSelector.DrawEnumField didn't draw the label provided.
  • Fixed case where setting new targets on a property tree would prevent prefab modifications from working properly.
  • Fixed issue where the ToggleGroup attribute would not respect setting CollapseOthersOnExpand to false when it has multiple members.
  • Fixed several issues where PropertyTrees was not properly disposed.
  • InspectorTypeDrawingConfigDrawer now uses SafeGetTypes() when retrieving types from assemblies, to protect itself from corrupt loaded assemblies.
  • PropertyTree's now ApplyChanges when disposed.
  • Range, MinMaxSlider, MaxValue and MinValue attribute drawers no longer immediately clamp the value to valid values when drawing; values are now only clamped to valid ranges when user input changes the values so that data does not mutate merely by inspecting it.
  • Reverting prefab modifications on a value now triggers OnValueChanged for that value.
  • Fixed multiple cases where TypeSearchIndex would incorrectly match many different types in ways that would later be filtered away. Type matching is now more precise to begin with, without need for further filtering.

Changes

  • Type matching for all drawers, validators, resolvers and processors has been changed to allow for polymorphic matching on non-generic targets. IE, public class UnityObjectDrawer : OdinValueDrawer<UnityEngine.Object> will now in fact match on and draw all UnityEngine.Object instances without needing to be generic and using generic constraints to match on those types instead.
  • TypeSearchIndex's match search API now requires you to pass in TargetMatchCategory values for each match target, both when indexing types and when matching them, in order to more precisely distinguish between which things to match as values and as attributes.
  • InspectorProperty.NiceName for ordered collection elements now takes the form of "CollectionNiceName [index]" instead of just "index".
  • Marked various obsolete members as being hidden from IDE intellisense
  • All debug symbol files for Odin's assemblies are now marked portable for better cross platform and cross Unity version compatibility.
  • Removed all deprecated features from Odin Validators.
  • Removed obsolete OpenGlobalConfigWindow.
  • SirenixGUIStyles.RichTextLabel now word wraps.
  • The overload of GUIHelper.RequestRepaint that takes an argument of how many frames it should repaint has been deprecated.