On the scene I have GameObject Cube
, and there is still a code in which the cube “turns off” when you press the D key like this:
if (input.ketkeyup (keycode.d))
{
Cube.SetActive (False);
}
But I want the cube to be disconnected and turned on on the same key, in the theory it is necessary that, each time clicking on D, SetActive has received the parameter of the current opposite value by the value of the value, but how to write this parameter concept does not have
Answer 1, Authority 100%
You can use the property gameobject.activeself :
cube.setActive (! cube.activeself);