Jump to content

F2 button does not hide my MonoBehaviour icon


Recommended Posts

Hi,

I am developing a plugin (Mission Controller) which draws an icon at the bottom of the screen. Sadly the plugin draws the icon even if the users presses F2 because I don't know how to listen to this event.

The plugin uses the MonoBehaviour class + the new KSPAddon annotation and draws the icon in the OnGUI method.

Any ideas?

Thanks!

Link to comment
Share on other sites

I've tried looking through all the stuff that KSP exposes but I have yet to find a specific event or property that signals when the GUI should or should not be displayed. So instead in my component's Update function I call Input.GetKeyDown(KeyCode.F2). That will detect when the user presses the F2 button. When that happens, I toggle a bool variable of my own that is then used in my OnGUI function to control whether I run my GUI code or not. This seems to work fine, although it's in a mod I haven't released yet...

Link to comment
Share on other sites

you could always just go the oldschool way of using RenderingManager:


RenderingManager.AddToPostDrawQueue(3, new Callback(this.someMethodName));

the callback will then be called in compliance with f2 behaviour.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...