- Home /
The question is answered, right answer was accepted
No suitable method found to override
Hey, I have a base class BlockManager, then I have two inherited classes BlockManagerClient and BlockManagerServer.
public abstract class BlockManager : MonoBehaviour
{
}
public class BlockManagerServer : BlockManager
{
}
public class BlockManagerClient : BlockManager
{
}
In these classes I've added abstract methods in it and everything worked fine, but today when I try and add an abstract method it does not work. I receive the errors no suitable method found to override.
In my classes I have something along the lines of:
public abstract class BlockManager : MonoBehaviour
{
public abstract void UpdatePosition (SnappableObject obj);
}
public class BlockManagerServer : BlockManager
{
public override void UpdatePosition (SnappableObject obj)
{
// Some code
}
}
public class BlockManagerClient : BlockManager
{
public override void UpdatePosition (SnappableObject obj)
{
// No Code
}
}
In the classes I have more abstract methods that Unity does not complain about, but for whatever reason it is complaining today.
Its especially weird because I can remove the methods from the inherited classes and Unity does not complain, but Visual studio complains that the classes are not implementing the abstract method. Then even when I use the Visual studio recommendation to just implement the class with a throw new exception, Unity still complains.
I had similar issues in the past, it happened after moving a file to another folder, for a strange reason, Visual Studio kept the old file location.
Ensure you have only one version of each file in your project
Close Visual Studio & Unity
Launch Unity again and then open Visual Studio again
Dang, just tried it and it didn't work. I don't have any duplicates anywhere else. I closed everything and reopened all of it. I even made visual studio regenerate the project files. Same issues still :/
I lied, I just went back into visual studio and it had the same error in Visual studio as Unity Editor, you were 100% correct, it was talking to a completely different version of the Block$$anonymous$$anager.cs file. I went to the correct one and implemented the abstract method, and it fixed it.
Thanks a million!