- Home /
 
 
               Question by 
               MechaWolf99 · Apr 17, 2018 at 03:31 AM · 
                editor-scriptingeditorguicustom-inspectorcustom-editor  
              
 
              How to force close Popup Window?
Hello, I got a seemingly simple problem. How to close a popup window without selecting off of it?
To be exact I got a popup window with a button. When I press the button I want the window to close, with out having to click off of the window. Any ideas would be much appreciated :) Relevant code:
 using UnityEngine;
 using UnityEditor;
 
 public class CustomPopup : PopupWindowContent {
 
    // Setup Stuff.
     public override Vector2 GetWindowSize()
     {
         return new Vector2(200, 150);
     }
 
     public override void OnGUI(Rect rect)
     {
         // But I wish to click to close window.
         if (GUILayout.Button("Close"))
         {           
             // Code to close popup window...
         }
     }
 }
 
              
               Comment
              
 
               
              Your answer