Exemplo n.º 1
0
        internal void Reload(object userData)
        {
            EditorWindow window = userData as EditorWindow;

            if (window == null)
            {
                return;
            }

            // Get some info on the existing window.
            Type windowType = window.GetType();

            // Save what we can of the window.
            string windowJson = EditorJsonUtility.ToJson(window);

            DockArea dockArea = window.m_Parent as DockArea;

            if (dockArea != null)
            {
                int windowIndex = dockArea.m_Panes.IndexOf(window);

                // Destroy window.
                dockArea.RemoveTab(window, false); // Don't kill dock if empty.
                DestroyImmediate(window, true);

                // Create window.
                window = EditorWindow.CreateInstance(windowType) as EditorWindow;
                dockArea.AddTab(windowIndex, window);
            }
            else
            {
                // Close the existing window.
                window.Close();

                // Recreate window.
                window = EditorWindow.CreateInstance(windowType) as EditorWindow;
                if (window != null)
                {
                    window.Show();
                }
            }

            // Restore what we can of the window.
            EditorJsonUtility.FromJsonOverwrite(windowJson, window);
        }
        public static void CreateLightmapPreviewWindow(int lightmapId, bool realtimeLightmap, bool indexBased)
        {
            LightmapPreviewWindow window = EditorWindow.CreateInstance <LightmapPreviewWindow>();

            window.minSize            = new Vector2(360, 390);
            window.isRealtimeLightmap = realtimeLightmap;

            if (indexBased)
            {
                window.lightmapIndex = lightmapId;
            }
            else
            {
                window.instanceID = lightmapId;
            }

            window.Show();
        }