Esempio n. 1
0
        /// <summary>
        /// Creates a new 'Sub Window' that acts like a window within this editor.
        /// Useful for quick-n-dirty solutions to things like movable controls,
        /// popup windows, dropdown lists, etc...
        /// </summary>
        /// <param name="position">The editor-relative position of the window.</param>
        /// <param name="updateHandler">A user-supplied method that is called each frame
        /// that the SubWindow is active.</param>
        /// <returns></returns>
        public SubWindow ShowSubwindow(Rect position, GUI.WindowFunction updateHandler, SubWindow.WindowType type, GUIStyle style = null)
        {
            var win = ShowSubwindow(WindowId, position, updateHandler, type, style);

            while (SubWindows.ContainsKey(WindowId))
            {
                WindowId++;
            }
            return(win);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new 'Sub Window' that acts like a window within this editor.
        /// Useful for quick-n-dirty solutions to things like movable controls,
        /// popup windows, dropdown lists, etc...
        /// </summary>
        /// <param name="position">The editor-relative position of the window.</param>
        /// <param name="updateHandler">A user-supplied method that is called each frame
        /// that the SubWindow is active.</param>
        /// <returns></returns>
        public SubWindow ShowSubwindow(int id, Rect position, GUI.WindowFunction updateHandler, SubWindow.WindowType type, GUIStyle style = null)
        {
            if (SubWindows.ContainsKey(id))
            {
                return(SubWindows[id]);
            }
            SubWindow sub = new SubWindow();

            sub.Position = GUI.Window(id, position, updateHandler, "", style);
            if (style != null)
            {
                sub.Style = style;
            }
            else
            {
                sub.Style = Skin.window;
            }
            sub.WindowId     = id;
            sub.HandleUpdate = updateHandler;
            sub.Type         = type;
            SubWindows[id]   = sub;

            //make sure to refocus controls so that
            //any delayed text boxes resets to current text
            GUI.FocusControl("");
            GUI.FocusWindow(id);

            return(sub);
        }