Error on build

I get the following error when attempting to build:

Assets/Scripts/Misc/Joystick.cs(129,41): error CS0115: `UnityEngine.UI.Joystick.OnValidate()' is marked as an override but no suitable method found to override

Here is the portion of the script it is referring to:

protected override void OnValidate() {
			base.OnValidate();
			UpdateJoystickGraphic();
		}

What should I do to fix this? I attempted erasing override from the void, but I got a warning saying:

Assets/Scripts/Misc/Joystick.cs(129,32): warning CS0114: `UnityEngine.UI.Joystick.OnValidate()' hides inherited member `UnityEngine.EventSystems.UIBehaviour.OnValidate()'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword

Replace it with :

#if UNITY_EDITOR
protected override void OnValidate()
{
    base.OnValidate();
    UpdateJoystickGraphic();
}
#endif

I am getting a similar cs0115 error in this

I cant remove the override either so i dont know what to do and the answer above looks the exact same as his problem…