Unity 2019.4.9f1 - Toggle Show/Hide Gameobject with one keystroke.

Hi all.

I have constructed a spiral freezer and want to simulate automated cleaning on it.

To do that I am making 9 “segments”, each consisting of an empty gameobject with several particle systems as children.

I would like to start with all segments hidden og then be able show/hide each segment when pressing keys 1-9.

By searching the web I found several answers, but all seem to be outdated?

Can anyone help me code show/hide a gameobject+children in one keystroke?

[SerializeField] private KeyCode m_Key = KeyCode.G;
[SerializeField] private GameObject m_Target;

private void Update ()
{
    if (m_Target != null && Input.GetKeyDown (m_Key))
        m_Target.SetActive (!m_Target.activeSelf);
}

Basic idea is to wait for the key press, then set the object active to the opposite of its current state.