My C# is not finding any instantiated class, i have the code bellow, and i cant even do “wood = 1”, its like the variable is not instantiated, the error says that the variable is not part of the context, any ideas? I tried on MonoDevelop and VisualStudio.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Inventory {
public int wood = null;
wood = 1; (this code says wood is not part of the context )
}
The syntax is wrong. Outside of methods you can assign values to variables with statements public int wood = 1;, but changing that value only works within other methods. The auto-complete is right about not showing it, because it’s the wrong place.
You should have a look at unity’s beginner section on C# and learn the syntax properly to avoid mistakes like that.