Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Get the current drawing target. Screen or EditorWindow/Popup

Discussion in 'Immediate Mode GUI (IMGUI)' started by zeonni, Oct 10, 2023.

  1. zeonni

    zeonni

    Joined:
    Apr 8, 2020
    Posts:
    2
    I'm developing a class that can draw the interface both in the game and in the editor.
    Now I manually specify which mode to work. Because some functions are not available in different modes

    Code (CSharp):
    1. class MyWindow : MonoBehaviour {
    2.   void OnGUI() {
    3.     myClass.OnGUI(GUIMode.Screen);
    4.   }
    5. }
    6.  
    7. class MyEditorWindow : EditorWindow {
    8.   void OnGUI() {
    9.     myClass.OnGUI(GUIMode.Inspector);
    10.   }
    11. }
    I would like to learn how to detect this automatically. Is it possible?