1

I get this error:

Error CS0122: 'GameManager.Instance' is inaccessible due to its protection level

If anybody knows how to solve this error, please tell me.

I am showing my code as a screenshot below:

image link :- https://i.stack.imgur.com/mKy2u.jpg

GameManager code link:- https://i.stack.imgur.com/RUxHS.jpg

1 Answers1

1

This is because access to the variable is limited, Make sure every variable you call from another class is public.

public static GameManager Instance;

for more info: (Public class is inaccessible due to its protection level)

KiynL
  • 4,097
  • 2
  • 16
  • 34
  • The [link](https://stackoverflow.com/questions/18404264/public-class-is-inaccessible-due-to-its-protection-level) you provided said the constructor is not accessible, OPs' Instance property is already Public. Mind explaining a littler more? – HardcoreGamer May 16 '22 at 02:11
  • (https://stackoverflow.com/questions/614818/in-c-what-is-the-difference-between-public-private-protected-and-having-no#:~:text=public%20%2D%20can%20be%20access%20by,inherits%20off%20of%20the%20class.) – KiynL May 16 '22 at 02:14
  • This my game manager code:- https://i.stack.imgur.com/RUxHS.jpg what should I change – Ravi Singh Chauhan 36 May 16 '22 at 04:05