Advertisement
Guest User

App launcher button

a guest
Aug 11th, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.63 KB | None | 0 0
  1.         // Hook to the event to add my button
  2.         public override void OnAwake()
  3.         {
  4.             GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady);
  5.         }
  6.  
  7.  
  8.     // Add the button to the toolbar
  9.         void OnGUIAppLauncherReady()
  10.         {
  11.             if (ApplicationLauncher.Ready)
  12.             {
  13.                 Debug.Log("About to add the app button...");
  14.  
  15.                 Texture btnTex = GameDatabase.Instance.GetTexture("DangIt/Textures/appBtn", false);
  16.  
  17.                 appBtn = ApplicationLauncher.Instance.AddModApplication(
  18.                             onAppBtnToggleOn,
  19.                             onAppBtnToggleOff,
  20.                             dummyVoid,
  21.                             dummyVoid,
  22.                             dummyVoid,
  23.                             dummyVoid,
  24.                             ApplicationLauncher.AppScenes.SPACECENTER,
  25.                             btnTex);
  26.             }
  27.         }
  28.  
  29.  
  30.     // Enable the GUI
  31.         void onAppBtnToggleOn()
  32.         {
  33.             newSettings = this.currentSettings.ShallowClone();
  34.             this.showGUI = true;            
  35.         }
  36.  
  37.  
  38.     // Disable the GUI
  39.         void onAppBtnToggleOff()
  40.         {
  41.             newSettings = null;
  42.             this.showGUI = false;
  43.         }
  44.  
  45.  
  46.     // Nothing
  47.         void dummyVoid()
  48.         {
  49.             return;
  50.         }
  51.  
  52.     // Draw the window when enabled
  53.         void OnGUI()
  54.         {
  55.             if (showGUI)
  56.             {
  57.                 GUI.skin = HighLogic.Skin;
  58.                 windowRect = GUILayout.Window(0, windowRect, WindowFunction, "DangIt! Settings");
  59.             }
  60.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement