Skip to content

Commit

Permalink
hide debug toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
Vivero committed May 3, 2020
1 parent ece9c02 commit b192b16
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions KerbalVR_Mod/KerbalVR/KerbalVR_AppGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ public static string APP_BUTTON_LOGO_ALT {

#region Private Members
protected ApplicationLauncherButton appMainButton = null;
#if DEBUG
protected ApplicationLauncherButton appDebugButton = null;
#endif
protected static GameObject uiMainCanvas = null;
protected static GameObject uiDebugCanvas = null;
#endregion
#endregion

protected void Awake() {
// when ready for a GUI, load it
Expand Down Expand Up @@ -68,19 +70,17 @@ public void OnAppLauncherReady() {
GameDatabase.Instance.GetTexture(APP_BUTTON_LOGO, false));
}

#if DEBUG
// create a debugging tools app button instance if it doesn't already exist
if (appDebugButton == null) {
appDebugButton = ApplicationLauncher.Instance.AddModApplication(
OnDebugToggleTrue,
OnDebugToggleFalse,
null, null, null, null,
#if DEBUG
ApplicationLauncher.AppScenes.ALWAYS,
#else
ApplicationLauncher.AppScenes.NEVER,
#endif
GameDatabase.Instance.GetTexture(APP_BUTTON_LOGO_ALT, false));
GameDatabase.Instance.GetTexture(APP_BUTTON_LOGO_ALT, false));
}
#endif

// load the UI prefab
if (uiMainCanvas == null) {
Expand Down Expand Up @@ -111,10 +111,12 @@ public void OnAppLauncherDestroyed() {
appMainButton.SetFalse(true);
ApplicationLauncher.Instance.RemoveApplication(appMainButton);
}
#if DEBUG
if (appDebugButton != null) {
appDebugButton.SetFalse(true);
ApplicationLauncher.Instance.RemoveApplication(appDebugButton);
}
#endif
}

/// <summary>
Expand All @@ -125,17 +127,18 @@ public void OnMainToggleTrue() {
}

/// <summary>
/// Callback when the debug application button is toggled on.
/// Callback when the main application button is toggled off.
/// </summary>
public void OnDebugToggleTrue() {
uiDebugCanvas.SetActive(true);
public void OnMainToggleFalse() {
uiMainCanvas.SetActive(false);
}

#if DEBUG
/// <summary>
/// Callback when the main application button is toggled off.
/// Callback when the debug application button is toggled on.
/// </summary>
public void OnMainToggleFalse() {
uiMainCanvas.SetActive(false);
public void OnDebugToggleTrue() {
uiDebugCanvas.SetActive(true);
}

/// <summary>
Expand All @@ -144,14 +147,17 @@ public void OnMainToggleFalse() {
public void OnDebugToggleFalse() {
uiDebugCanvas.SetActive(false);
}
#endif

/// <summary>
/// Callback when the game changes scenes.
/// </summary>
protected void OnSceneChange(GameEvents.FromToAction<GameScenes, GameScenes> fromToScenes) {
// on scene change, command the button to toggle off, so the GUI closes
appMainButton.SetFalse(true);
#if DEBUG
appDebugButton.SetFalse(true);
#endif
}
}

Expand Down Expand Up @@ -310,9 +316,9 @@ void OnHmdStatusUpdated(bool isRunning) {

public class AppDebugGUI : AppGUI
{
#region Private Members
#region Private Members
private Text debugText;
#endregion
#endregion

private void Awake() {
// get text label objects
Expand Down

0 comments on commit b192b16

Please sign in to comment.