void DoPlayButtons(bool isOrWillEnterPlaymode) { // Enter / Exit Playmode bool isPlaying = EditorApplication.isPlaying; GUI.changed = false; int buttonOffset = isPlaying ? 4 : 0; Color c = GUI.color + new Color(.01f, .01f, .01f, .01f); GUI.contentColor = new Color(1.0f / c.r, 1.0f / c.g, 1.0f / c.g, 1.0f / c.a); GUI.SetNextControlName("ToolbarPlayModePlayButton"); GUILayout.Toggle(isOrWillEnterPlaymode, s_PlayIcons[buttonOffset], isPlaying ? Styles.commandLeftOn : Styles.commandLeft); GUI.backgroundColor = Color.white; if (GUI.changed) { EditorApplication.TogglePlaying(); GUIUtility.ExitGUI(); } // Pause game GUI.changed = false; buttonOffset = EditorApplication.isPaused ? 4 : 0; GUI.SetNextControlName("ToolbarPlayModePauseButton"); bool isPaused = GUILayout.Toggle(EditorApplication.isPaused, s_PlayIcons[buttonOffset + 1], Styles.commandMid); if (GUI.changed) { EditorApplication.isPaused = isPaused; GUIUtility.ExitGUI(); } using (new EditorGUI.DisabledScope(!isPlaying)) { // Step playmode GUI.SetNextControlName("ToolbarPlayModeStepButton"); if (GUILayout.Button(s_PlayIcons[2], Styles.commandRight)) { EditorApplication.Step(); GUIUtility.ExitGUI(); } } }