Validate Unity Inspector Input with OnValidate - Quick Tip @WorldOfZeroDevelopment
Validate Unity Inspector Input with OnValidate - Quick Tip  @WorldOfZeroDevelopment
Uploaded April 2019 | Updated November 2026, 2 hours ago
Unity provides a funtion that allows your MonoBehaviors to be alerted when values are changed on it in the inspector. The `OnValidate` method is invoked every time you modify a value in the inspector (only the inspector, changes to the value via code don't publish any alerts). This makes it possible to validate your modifications in a way that makes sense. In our example we'll use a min and max value where the min/max function as limits on one another so the min value can't exceed the max value.

An example that logs a notification every time you modify the value might look like this:

```csharp
public void OnValidate() {
Debug.Log("The Unity Inspector Has Detected an Update");
}
```

Join the World of Zero Discord Server: discord.gg/hU5Kq2u
Validate Unity Inspector Input with OnValidate - Quick TipRunning a Minecraft Server in DockerCreating a Context Menu in Custom Unity EditorsGetting Started with Pathfinding using Dijkstras AlgorithmLearning to Deserialize YAML in C# with YamlDotNETSpinning In Circles and Other Mischief - Building Asteroids VR - Day 2Tracking Rigidbody Velocity in Asteroids VRIntroducing Testing into our PlatformerThe Search for Objects - Unity Observer - Part 1Using Your Terminals Directory Stack to Work With Multiple DirectoriesUsing Polar Coordinates in Unity Shader GraphsLets Explore Implicit Usings in C# 10
World of Zero |

Validate Unity Inspector Input with OnValidate - Quick Tip

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER