Accessing object's variable in inspector

I am creating a new object from a class and I want to access their variables from inspector panel.

public class Location
{
public int x;
}

public class MyGUI : MonoBehaviour
{
public Location location = new Location();
}

I added MyGUI script to a gameobject and I want to access x from inspector panel. How can I access? Any help.

Thank you.

Hi. Try, putting the Serializable attribute on top of the class, like this:

[System.Serializable]
public class Location { public int x; }

That should solve it.