Override BaseVertexEffect error when building for WebGL

Hello guys!

I am receiving an error compiling to WebGL when overriding a method already overridden by parent class. You can follow the next steps to reproduce:

1 - Inheriting from class BaseVertexEffect, inside namespace UnityEngine.UI.

2 - Override the method OnValidate, like: protected override void OnValidate().

3 - Build for WebGL.

You will get next error log:
‘ChildClass.OnValidate()’ is marked as an override but no suitable method found to override’

The compiler should find the method from the parent classes and it should be able to override it. this is probably happening for all classes where this case apply.

I already file a bug report to the Unity team but without avail, I havent’t heard from them… :frowning:

This seems to be a Unity bug, but I found an easy workaround:

Simply wrap the OnValidate method with the “#if UNITY_EDITOR” directive, like so:

		protected override void OnValidate ()
			base.OnValidate ();

OnValidate is an Editor-only method, so it shouldn’t cause any issues with your build :),

let me know if it works!