Skip to content

Instantly share code, notes, and snippets.

@lynxelia
Last active February 11, 2018 06:29
Show Gist options
  • Save lynxelia/24aaaf4696610ee8c53e0046cde9ed86 to your computer and use it in GitHub Desktop.
Save lynxelia/24aaaf4696610ee8c53e0046cde9ed86 to your computer and use it in GitHub Desktop.
A replacement base class to use instead of MonoBehaviour. Inheriting from this class will allow you to validate properties without encountering the OnValidate garbage collection bug. OnValidateProperty is also guaranteed to only execute when a change is made in the Inspector Window. It doesn't run when loading an asset into memory or loading a s…
public class BaseMonoBehaviour : MonoBehaviour
{
public virtual bool OnValidateProperty(string propertyName)
{
return false;
}
// Remember to include the OnDestroy code from Step 3 as well
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment