The type or namespace name 'State' could not be found

I have been getting this error for the past couple of days. Tried searching on the web but wasn’t able to find a proper answer.

Assets\AdventureGame.cs(10,22): error CS0246: The type or namespace name ‘State’ could not be found (are you missing a using directive or an assembly reference?)

Help!!! I am unable to proceed with my course due to this.
Thanks
Anirudha Duttagupta

Hi Anirudha,

Welcome to our community. :slight_smile:

Does the file name match the class name inside the file? For example, is the State class inside the State.cs file? If so, please watch lecture “Fixing Visual Studio Problems” (currently #4).

Did this help?

Yes both matched. I followed Ben religiously😂. However when i replaced the ‘state’ declaration while declaring the ‘startingState’ to ‘ScriptableObject’, Unity stopped showing me the error. This is the syntax which worked:
[SerializeField] ScriptableObject startingState;
This is the one which did not and showed me the orignal error:
[SerializeField] state startingState;

Thanks,
Anirudha

C# is case-sensitive. Ben’s class is named “State” with a capital S. If yours is named State, too, the issue was probably caused by the little typo: state.

This topic was automatically closed after 5 hours. New replies are no longer allowed.

Privacy & Terms