Trying to understand this abstract code (and use it elsewhere)
I am trying to get access to SimpleRandomWalkDungeonGenerator.RunProceduralGeneration from another class but I understand that it is protected. I'm not sure how get access to that function without removing abstract from AbstractDungeonGenerator (stuffs will break). Does anyone have any suggestions?
9 Replies
Just make it public instead of protected?
But that introduces:
SimpleRandomWalkDungeonGenerator.RunProceduralGeneration()': cannot change access modifiers when overriding 'protected' inherited member 'AbstractDungeonGenerator.RunProceduralGeneration()'
Can't you make it public in the abstract class as well?
When I did that I had to make other changes to for things to be public but then I now get this error:
Something you're trying to access is
null
tilemapVisualizer.Clear();
tileMapVisualizer is now null
I'm guessing the protected override void RunProceduralGeneration()
on that function caused the tilemapVisualizer to be null?Maybe?
I'd use a debugger to see when and what becomes null
It seems that
protected TilemapVisualizer tilemapVisualizer = null;
, when making things abstract/protected/private, the variable tilemapVisualizer
was not null, but now that I made things public, this variable is Null and is not being set like before.Nullability rarely has anything to do with accessibility