Struggling to understand why I am getting the following error message –
Inconsistent Accessibility: Parameter type "GameModesMenu.GameMode" is less accessible than method "GameModesMenu.SelectedGameModeTextObject(GameMode _gameModeSelected)"
This is what my code looks like:
enum GameMode{None, PlayerVsAi1v1};
private GameMode gameModeSelected = GameMode.None;
public void PlayerVsAiOneVsOne()
{
gameModeSelected = GameMode.PlayerVsAi1v1;
SelectedGameModeTextObject(gameModeSelected);
}
public void SelectedGameModeTextObject(GameMode _gameModeSelected)
{
Debug.Log(_gameModeSelected);
}
The error message goes away when I add the "public" access modifier to the enum like so:
public enum GameMode{None, PlayerVsAi1v1};
But I don’t understand why that works. I also don’t understand why I can access it with no problems within the methods, but the error only occurs when I pass it as a parameter.
>Solution :
Since the method is public, the enum parameter must also be public, so that it will be visible to the outer world.