- Home /
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... :(
Answer by oddgoo · Jul 31, 2015 at 01:25 AM
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:
#if UNITY_EDITOR
protected override void OnValidate ()
{
base.OnValidate ();
}
#endif
OnValidate is an Editor-only method, so it shouldn't cause any issues with your build :),
let me know if it works!
It worked! Thanks a lot oddgoo!!
That is so weird, because as you know OnValidate method is in the $$anonymous$$onoBehaviour class. (check here)
They should be checking this when compiling, unless the unity $$anonymous$$m does not have a way to do is, otherwise is definitely a bug.
Thanks again! Greatly appreciate your help! :) Best regards, Lermy