hey -
I’ve attempted to update a project to 3.1 (still have the 2.6 backup) and the first compilation error is this
error CS0106: The modifier `virtual' is not valid for this item
This code has worked fine for the project life whilst on 2.6.
Can we not create virtual classes now from a Monobehavior?
If I remove the virtual keyword it compiles, though the class is made up of many virtual functions that inheriting classes use. So I’m curious what in 3.1 may have caused this error?
Sorry if this has been dealt with already, I did try searching. Is there perhaps a “What you need to know” about updating a project to 3.1?
mono 1.2.5 as used in unity iphone 1.x / unity 2.x was pretty buggy when it comes to especially virtual and where its valid or more appropriately where it is especially not.
For example, there are no virtual variables in classes nor virtual classes at all (virtual classes would be Abstract classes).
Also, it should be rather clear that you can not make a class “unreal” thats fully implemented (like the whole MonoBehaviour inheritance tree), you will need to write own abstract classes or use Interfaces which you implement in monobehaviour extending classes for the purpose of defining “protocols” or blueprints
the only thing that exists in virtual is methods, which you then implement in extending classes through override.
Problem:
In the earlier version of Mono we used pre-3.0, the virtual keyword was incorrectly allowed in a ton of places. These placements of the keyword didn’t even have any effect on execution.
Fix:
For each error message, remove virtual keyword.
The execution of your project should be exactly the same.