Can I combine or place two actions insife an if statement (something like &&) so that fullscreen can be toggled with either the GUI button or the hotkey?
function OnGUI() {
if(GUILayout.Button("Fullscreen"))
Screen.fullScreen = !Screen.fullScreen;
if (Input.GetKeyDown(KeyCode.F))
Screen.fullScreen = !Screen.fullScreen;
Yes, use a else if-statement and then you can use it:
if(GUILayout.Button("Fullscreen"))
Screen.fullScreen = !Screen.fullScreen;
else if (Input.GetKeyDown(KeyCode.F))
Screen.fullScreen = !Screen.fullScreen;
This means, that if the first if-statement ( the ‘if(GUILayout.Button(“Fullscreen”))’ part) is false, then it will check the next else if-statement.
If the first if-statement is true, then it will not check the second else if-statement.
You can also do it like this:
if(GUILayout.Button("Fullscreen") == true || Input.GetKeyDown(KeyCode.F) == true)
Screen.fullScreen = !Screen.fullScreen;
The ‘||’ means or in this case. But it might be little harder to read. Specially if you have more than two ‘||’ statements in a if-statement.
Good luck!