Jump to content

Simple way to know if debug menu is open?


Recommended Posts

If you're polling instead of an infrequent check, it might be best to add a little tracking component to DebugScreen that updates a visible flag whenever OnEnable or OnDisable get called on it. The FindObject(s) family are all fairly slow

Edited by xEvilReeperx
Link to comment
Share on other sites

8 hours ago, Thomas P. said:

UnityEngine.Object.FindObjectsOfType<KSP.UI.Screens.DebugToolbar.DebugScreen>().Any(s => s.isShown);

I think this could work for you, but I am not sure.

I couldn't figure out how to get that to work so I went my typical path and bodged something into existence. It looks at input locks and see's if the ones that the debug menu implements are active.

bool checkDebug()
{
  	string both = "Current Input Locks:\nDebugToolbar\nDebugConsole\n-- \nbitmask: 111101111111111111111111111111111111111111111111111111111111";
	string console = "Current Input Locks:\nDebugConsole\n-- \nbitmask: 111101111111111111111111111111111111111111111111111111111111";
	string toolbar = "Current Input Locks:\nDebugToolbar\n-- \nbitmask: 110001111111111111111111111111111111111111111111101011111111";
	string checker;
	bool debugIsOpen;

	checker = InputLockManager.PrintLockStack();
	if (checker == console || checker == toolbar || checker == both)
	{
		debugIsOpen = true;
	}
	else
	{
		debugIsOpen = false;
	}
    return debugIsOpen;
}
Edited by TheRagingIrishman
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...