Jump to content

right click GUI? and GUI in General


Recommended Posts

anyone one know what the code is to A. create a small gui, and B. know how to make that small GUI appear when the button in the right-click window is pressed, and C. know how to make the Right-Click GUI appear?

Link to comment
Share on other sites

GUI I haven't done yet but here's the 'right-click' window on a part.

//motion lock start

[KSPEvent(guiActive = true, guiName = "Engage Lock")]

public void Activate()

{

isRotationLock = true;

Events["Activate"].active = false;

Events["Deactivate"].active = true;

}

[KSPEvent(guiActive = true, guiName = "Disengage Lock", active = false)]

public void Deactivate()

{

isRotationLock = false;

Events["Activate"].active = true;

Events["Deactivate"].active = false;

}

//motion lock stop

Link to comment
Share on other sites

A) See https://github.com/taraniselsu/TacLib/blob/master/Source/Window.cs and what evilC has done with it: https://github.com/evilC/TacLib/blob/master/Source/TacWindowTest.cs

Basically you use GUILayout.Window to tell Unity to display the window (http://docs.unity3d.com/Documentation/ScriptReference/GUILayout.Window.html).

But you need to do that within Unity's OnGUI() method or in a method called by KSP's RenderingManager (https://github.com/taraniselsu/TacLib/blob/master/Source/Window.cs#L76). The second way is recommended more, because you can properly hide your window when the user hides the UI (presses F2) and when the PauseMenu is displayed.

B & C) See https://github.com/evilC/TacLib/blob/master/Source/TacWindowTest.cs#L71.

Basically you mark a method with the KSPEvent attribute. That makes it show up when you right click a part. Inside that method, do something to show or hide your window. evilC's code is calling SetVisible(true) on the Window class which makes sure the window is added to KSP's post-draw queue.

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...