Grouping variables in inspector with a serailized class not working

Hi

I’m trying to organize my variables into groups by making a serialized class and then using them in another, but it gives me errors saying the variables I declared in the serialized class don’t exist. Here’s the code I’m using

[System.Serializable]
public class DisplayOptions
{
	public bool ViewInGame = false;

	public bool ViewInEditor = false;
}

public class NewGameObject : MonoBehaviour {


	public DisplayOptions displayOptions;

protected void Update()
	{
		GetComponent<MeshRenderer>().enabled = ViewInGame;
	}

}

When looking for help with compiler errors, please include those errors verbatim. It makes it a lot easier for experts to help you.

Now, this line:

GetComponent<MeshRenderer>().enabled = ViewInGame;

Should probably look more like this:

GetComponent<MeshRenderer>().enabled = displayOptions.ViewInGame;

You can embed one object in another, but when accessing its variables you’ll need to clarify scope.