I am getting the following warning in unity. The code in question is not actually hidden as I am using the base. keyword to access it. In this case I am triggering the code using a notification manager that does not work correctly with the base class (I believe because it is abstract and, therefore, not actually instantiated?). Since the code is long and used the same in all derived classes I put it in the base class so I don’t repeat myself with the same long block of code in all the derived classes.
The error is:
Assets/Scripts/Map/MapGenLoad.cs(76,18): warning CS0114: MapGenLoad.MapSavePrepare()' hides inherited member
MapGenerator.MapSavePrepare()'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword
// This is the part of the derived class causing the error
public class MapGenLoad : MapGenerator
}
private void MapSavePrepare()
{
base.MapSavePrepare();
}
}
// This is the base class and part of the method in question
public abstract class MapGenerator : MonoBehaviour
{
public virtual void MapSavePrepare()
{
Debug.Log("Saving Map: " + Application.persistentDataPath);
SerializationManager.MapStateData.DataMap thisMap = GameManager.Serializer.GameMapState.SaveMap;
thisMap.SaveFeatures.Clear();
thisMap.DataDungeonLevel = Map.DungeonDepth;
thisMap.DataMapSizeX = Map.MapSizeX;
thisMap.DataMapSizeY = Map.MapSizeY;
thisMap.DataLevelMapArray = new string[thisMap.DataMapSizeX];
thisMap.DataIsWalkableArray = new string[thisMap.DataMapSizeX];
// ... CODE CONTINUES
}
}
Is this safe to ignore or should I actually be overriding the method even though all I am doing is calling back to the base?
Note: Should there be a tag for Inheritance?