Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Scene view GUI.Window Draws Between 2 editorWindow

Discussion in 'Editor & General Support' started by usernameHed, Jul 19, 2019.

  1. usernameHed

    usernameHed

    Joined:
    Apr 5, 2016
    Posts:
    45
    Hello, I have a complexe problem, I have a simple script who create an window in the scene view:



    I would like to be able to put between the first and the end some stuff, from an outside EditorWindow.
    Here I am in an EditorWindow in the OnGUI() method:

    Code (CSharp):
    1. NavigatorDraggable nav = new NavigatorDraggable();
    2. nav.Init(0, 0, 120, 300);
    3. nav.ShowEditorWindow(StuffToLoad);
    4.  
    5. public void StuffToLoad()
    6. {
    7.       Debug.Log("ici");
    8.       GUILayout.Label("inside");
    9. }
    And here is my NavigatorDraggable struct, i use a delegate for passing my function into parametter, but I have also tryed Action, it doen't work neither...

    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public struct NavigatorDraggable
    7. {
    8.     private Rect _windowMenu;
    9.  
    10.     public delegate void ContentToDrawDelegate();
    11.     public ContentToDrawDelegate m_methodToCall;
    12.  
    13.     public void Init(float x, float y, float width, float height)
    14.     {
    15.         _windowMenu = new Rect(x, y, width, height);
    16.     }
    17.  
    18.     /// <summary>
    19.     /// called every frame,
    20.     /// </summary>
    21.     /// <param name="action"></param>
    22.     public void ShowEditorWindow(ContentToDrawDelegate action)
    23.     {
    24.         m_methodToCall = action;
    25.         _windowMenu = GUI.Window(0, _windowMenu, NavigatorWindow, "Navigator  ");
    26.     }
    27.  
    28.     private void NavigatorWindow(int id)
    29.     {
    30.         GUI.DragWindow(new Rect(0, 0, 120 - 20, 20));  //allow to drag de window only at the top
    31.  
    32.         GUILayout.Label("first");
    33.         m_methodToCall();
    34.         GUILayout.Label("end");
    35.     }
    36. }
    In the console, "ici" is printed, so the delegate or Action work, but nothing is drawn inside the Navigator between "first" and "and", why ?