Exemplo n.º 1
0
        private void OnContentDestroyed(Transform content)
        {
            string windowTypeName = m_windows.Where(kvp => kvp.Value.Contains(content)).Select(kvp => kvp.Key).FirstOrDefault();

            if (!string.IsNullOrEmpty(windowTypeName))
            {
                HashSet <Transform> windowsOfType = m_windows[windowTypeName];
                windowsOfType.Remove(content);

                if (windowsOfType.Count == 0)
                {
                    m_windows.Remove(windowTypeName);
                }

                List <Transform> extraComponents = new List <Transform>();
                if (m_extraComponents.TryGetValue(content, out extraComponents))
                {
                    for (int i = 0; i < extraComponents.Count; ++i)
                    {
                        Destroy(extraComponents[i].gameObject);
                    }
                }

                bool             isDialog;
                WindowDescriptor wd = m_windowManager.GetWindowDescriptor(windowTypeName, out isDialog);
                if (wd != null)
                {
                    wd.Created--;
                    Debug.Assert(wd.Created >= 0);

                    if (WindowDestroyed != null)
                    {
                        WindowDestroyed(content);
                    }
                }
            }

            RenderTextureCamera[] rtc = FindObjectsOfType <RenderTextureCamera>();
            for (int i = 0; i < rtc.Length; ++i)
            {
                if (rtc[i] != null)
                {
                    rtc[i].TryResizeRenderTexture();
                }
            }

            ForceLayoutUpdate();
            if (m_coForceUpdateLayout == null && !m_lockUpdateLayout)
            {
                m_coForceUpdateLayout = CoForceUpdateLayout();
                StartCoroutine(m_coForceUpdateLayout);
            }
        }
Exemplo n.º 2
0
        private void ActivateContent(WindowDescriptor wd, GameObject content)
        {
            List <Transform> extraComponentsList = new List <Transform>();

            m_extraComponents.TryGetValue(content.transform, out extraComponentsList);
            for (int i = 0; i < extraComponentsList.Count; ++i)
            {
                extraComponentsList[i].gameObject.SetActive(true);
            }

            wd.ContentPrefab.SetActive(true);
            content.SetActive(true);
        }
Exemplo n.º 3
0
        private void OnContentDestroyed(Transform content)
        {
            string windowTypeName = m_windows.Where(kvp => kvp.Value.Contains(content)).Select(kvp => kvp.Key).FirstOrDefault();

            if (!string.IsNullOrEmpty(windowTypeName))
            {
                HashSet <Transform> windowsOfType = m_windows[windowTypeName];
                windowsOfType.Remove(content);

                if (windowsOfType.Count == 0)
                {
                    m_windows.Remove(windowTypeName);
                }

                List <Transform> extraComponents = new List <Transform>();
                if (m_extraComponents.TryGetValue(content, out extraComponents))
                {
                    for (int i = 0; i < extraComponents.Count; ++i)
                    {
                        Destroy(extraComponents[i].gameObject);
                    }
                }

                WindowDescriptor wd = null;
                if (windowTypeName == RuntimeWindowType.Scene.ToString().ToLower())
                {
                    wd = m_sceneWindow;
                }
                else if (windowTypeName == RuntimeWindowType.Game.ToString().ToLower())
                {
                    wd = m_gameWindow;
                }
                else if (windowTypeName == RuntimeWindowType.Hierarchy.ToString().ToLower())
                {
                    wd = m_hierarchyWindow;
                }
                else if (windowTypeName == RuntimeWindowType.Inspector.ToString().ToLower())
                {
                    wd = m_inspectorWindow;
                }
                else if (windowTypeName == RuntimeWindowType.Project.ToString().ToLower())
                {
                    wd = m_projectWindow;
                }
                else if (windowTypeName == RuntimeWindowType.Console.ToString().ToLower())
                {
                    wd = m_consoleWindow;
                }
                else if (windowTypeName == RuntimeWindowType.SaveScene.ToString().ToLower())
                {
                    wd = m_saveSceneDialog;
                }
                else if (windowTypeName == RuntimeWindowType.OpenProject.ToString().ToLower())
                {
                    wd = m_openProjectDialog;
                }
                else if (windowTypeName == RuntimeWindowType.ToolsPanel.ToString().ToLower())
                {
                    wd = m_toolsWindow;
                }
                else if (windowTypeName == RuntimeWindowType.SelectAssetLibrary.ToString().ToLower())
                {
                    wd = m_selectAssetLibraryDialog;
                }
                else if (windowTypeName == RuntimeWindowType.ImportAssets.ToString().ToLower())
                {
                    wd = m_importAssetsDialog;
                }
                else if (windowTypeName == RuntimeWindowType.About.ToString().ToLower())
                {
                    wd = m_aboutDialog;
                }
                else if (windowTypeName == RuntimeWindowType.SelectObject.ToString().ToLower())
                {
                    wd = m_selectObjectDialog;
                }
                else if (windowTypeName == RuntimeWindowType.SelectColor.ToString().ToLower())
                {
                    wd = m_selectColorDialog;
                }
                else
                {
                    CustomWindowDescriptor cwd;
                    if (m_typeToCustomWindow.TryGetValue(windowTypeName, out cwd))
                    {
                        wd = cwd.Descriptor;
                    }
                }

                if (wd != null)
                {
                    wd.Created--;
                    Debug.Assert(wd.Created >= 0);
                }
            }
        }
Exemplo n.º 4
0
        public Transform CreateWindow(string windowTypeName, out WindowDescriptor wd, out GameObject content, out bool isDialog)
        {
            if (m_dockPanels == null)
            {
                Debug.LogError("Unable to create window. m_dockPanels == null. Set DockPanels field");
            }

            windowTypeName = windowTypeName.ToLower();
            wd             = null;
            content        = null;
            isDialog       = false;

            if (windowTypeName == RuntimeWindowType.Scene.ToString().ToLower())
            {
                wd = m_sceneWindow;
            }
            else if (windowTypeName == RuntimeWindowType.Game.ToString().ToLower())
            {
                wd = m_gameWindow;
            }
            else if (windowTypeName == RuntimeWindowType.Hierarchy.ToString().ToLower())
            {
                wd = m_hierarchyWindow;
            }
            else if (windowTypeName == RuntimeWindowType.Inspector.ToString().ToLower())
            {
                wd = m_inspectorWindow;
            }
            else if (windowTypeName == RuntimeWindowType.Project.ToString().ToLower())
            {
                wd = m_projectWindow;
            }
            else if (windowTypeName == RuntimeWindowType.Console.ToString().ToLower())
            {
                wd = m_consoleWindow;
            }
            else if (windowTypeName == RuntimeWindowType.ToolsPanel.ToString().ToLower())
            {
                wd = m_toolsWindow;
            }
            else if (windowTypeName == RuntimeWindowType.SaveScene.ToString().ToLower())
            {
                wd       = m_saveSceneDialog;
                isDialog = true;
            }
            else if (windowTypeName == RuntimeWindowType.OpenProject.ToString().ToLower())
            {
                wd       = m_openProjectDialog;
                isDialog = true;
            }
            else if (windowTypeName == RuntimeWindowType.SelectAssetLibrary.ToString().ToLower())
            {
                wd       = m_selectAssetLibraryDialog;
                isDialog = true;
            }
            else if (windowTypeName == RuntimeWindowType.ImportAssets.ToString().ToLower())
            {
                wd       = m_importAssetsDialog;
                isDialog = true;
            }
            else if (windowTypeName == RuntimeWindowType.About.ToString().ToLower())
            {
                wd       = m_aboutDialog;
                isDialog = true;
            }
            else if (windowTypeName == RuntimeWindowType.SelectObject.ToString().ToLower())
            {
                wd       = m_selectObjectDialog;
                isDialog = true;
            }
            else if (windowTypeName == RuntimeWindowType.SelectColor.ToString().ToLower())
            {
                wd       = m_selectColorDialog;
                isDialog = true;
            }
            else
            {
                CustomWindowDescriptor cwd;
                if (m_typeToCustomWindow.TryGetValue(windowTypeName, out cwd))
                {
                    wd       = cwd.Descriptor;
                    isDialog = cwd.IsDialog;
                }
            }

            if (wd == null)
            {
                Debug.LogWarningFormat("{0} window was not found", windowTypeName);
                return(null);
            }

            if (wd.Created >= wd.MaxWindows)
            {
                return(null);
            }
            wd.Created++;

            if (wd.ContentPrefab != null)
            {
                wd.ContentPrefab.SetActive(false);
                content      = Instantiate(wd.ContentPrefab);
                content.name = windowTypeName;

                Transform[] children = content.transform.OfType <Transform>().ToArray();
                for (int i = 0; i < children.Length; ++i)
                {
                    Transform component = children[i];
                    if (!(component is RectTransform))
                    {
                        component.gameObject.SetActive(false);
                        component.transform.SetParent(m_componentsRoot, false);
                    }
                }

                List <Transform> extraComponents = new List <Transform>();
                for (int i = 0; i < children.Length; ++i)
                {
                    if (children[i].parent == m_componentsRoot)
                    {
                        extraComponents.Add(children[i]);
                    }
                }

                m_extraComponents.Add(content.transform, extraComponents);
            }
            else
            {
                Debug.LogWarningFormat("{0} WindowDescriptor.ContentPrefab is null", windowTypeName);

                content = new GameObject();
                content.AddComponent <RectTransform>();
                content.name = "Empty Content";

                m_extraComponents.Add(content.transform, new List <Transform>());
            }

            HashSet <Transform> windows;

            if (!m_windows.TryGetValue(windowTypeName, out windows))
            {
                windows = new HashSet <Transform>();
                m_windows.Add(windowTypeName, windows);
            }

            windows.Add(content.transform);
            return(content.transform);
        }
Exemplo n.º 5
0
        public WindowDescriptor GetWindowDescriptor(string windowTypeName, out bool isDialog)
        {
            WindowDescriptor wd = null;

            isDialog = false;
            if (windowTypeName == null)
            {
                return(null);
            }

            windowTypeName = windowTypeName.ToLower();
            if (windowTypeName == RuntimeWindowType.Scene.ToString().ToLower())
            {
                wd = m_sceneWindow;
            }
            else if (windowTypeName == RuntimeWindowType.Game.ToString().ToLower())
            {
                wd = m_gameWindow;
            }
            else if (windowTypeName == RuntimeWindowType.Hierarchy.ToString().ToLower())
            {
                wd = m_hierarchyWindow;
            }
            else if (windowTypeName == RuntimeWindowType.Inspector.ToString().ToLower())
            {
                wd = m_inspectorWindow;
            }
            else if (windowTypeName == RuntimeWindowType.Project.ToString().ToLower())
            {
                wd = m_projectWindow;
            }
            else if (windowTypeName == RuntimeWindowType.Console.ToString().ToLower())
            {
                wd = m_consoleWindow;
            }
            else if (windowTypeName == RuntimeWindowType.Animation.ToString().ToLower())
            {
                wd = m_animationWindow;
            }
            else if (windowTypeName == RuntimeWindowType.ToolsPanel.ToString().ToLower())
            {
                wd = m_toolsWindow;
            }
            else if (windowTypeName == RuntimeWindowType.SaveScene.ToString().ToLower())
            {
                wd       = m_saveSceneDialog;
                isDialog = true;
            }
            else if (windowTypeName == RuntimeWindowType.SaveAsset.ToString().ToLower())
            {
                wd       = m_saveAssetDialog;
                isDialog = true;
            }
            else if (windowTypeName == RuntimeWindowType.OpenProject.ToString().ToLower())
            {
                wd       = m_openProjectDialog;
                isDialog = true;
            }
            else if (windowTypeName == RuntimeWindowType.SelectAssetLibrary.ToString().ToLower())
            {
                wd       = m_selectAssetLibraryDialog;
                isDialog = true;
            }
            else if (windowTypeName == RuntimeWindowType.ImportAssets.ToString().ToLower())
            {
                wd       = m_importAssetsDialog;
                isDialog = true;
            }
            else if (windowTypeName == RuntimeWindowType.About.ToString().ToLower())
            {
                wd       = m_aboutDialog;
                isDialog = true;
            }
            else if (windowTypeName == RuntimeWindowType.SelectObject.ToString().ToLower())
            {
                wd       = m_selectObjectDialog;
                isDialog = true;
            }
            else if (windowTypeName == RuntimeWindowType.SelectColor.ToString().ToLower())
            {
                wd       = m_selectColorDialog;
                isDialog = true;
            }
            else if (windowTypeName == RuntimeWindowType.SelectAnimationProperties.ToString().ToLower())
            {
                wd       = m_selectAnimationPropertiesDialog;
                isDialog = true;
            }
            else if (windowTypeName == RuntimeWindowType.SaveFile.ToString().ToLower())
            {
                wd       = m_saveFileDialog;
                isDialog = true;
            }
            else if (windowTypeName == RuntimeWindowType.OpenFile.ToString().ToLower())
            {
                wd       = m_openFileDialog;
                isDialog = true;
            }
            else
            {
                CustomWindowDescriptor cwd;
                if (m_typeToCustomWindow.TryGetValue(windowTypeName, out cwd))
                {
                    wd       = cwd.Descriptor;
                    isDialog = cwd.IsDialog;
                }
            }

            return(wd);
        }
Exemplo n.º 6
0
 public Transform CreateWindow(string windowTypeName, out WindowDescriptor wd, out GameObject content, out bool isDialog)
 {
     return(ActiveWorkspace.CreateWindow(windowTypeName, out wd, out content, out isDialog));
 }
Exemplo n.º 7
0
        public void OverrideWindow(string windowTypeName, WindowDescriptor descriptor)
        {
            windowTypeName = windowTypeName.ToLower();

            if (windowTypeName == RuntimeWindowType.Scene.ToString().ToLower())
            {
                m_sceneWindow = descriptor;
            }
            else if (windowTypeName == RuntimeWindowType.Game.ToString().ToLower())
            {
                m_gameWindow = descriptor;
            }
            else if (windowTypeName == RuntimeWindowType.Hierarchy.ToString().ToLower())
            {
                m_hierarchyWindow = descriptor;
            }
            else if (windowTypeName == RuntimeWindowType.Inspector.ToString().ToLower())
            {
                m_inspectorWindow = descriptor;
            }
            else if (windowTypeName == RuntimeWindowType.Project.ToString().ToLower())
            {
                m_projectWindow = descriptor;
            }
            else if (windowTypeName == RuntimeWindowType.Console.ToString().ToLower())
            {
                m_consoleWindow = descriptor;
            }
            else if (windowTypeName == RuntimeWindowType.Animation.ToString().ToLower())
            {
                m_animationWindow = descriptor;
            }
            else if (windowTypeName == RuntimeWindowType.SaveScene.ToString().ToLower())
            {
                m_saveSceneDialog = descriptor;
            }
            else if (windowTypeName == RuntimeWindowType.SaveAsset.ToString().ToLower())
            {
                m_saveAssetDialog = descriptor;
            }
            else if (windowTypeName == RuntimeWindowType.OpenProject.ToString().ToLower())
            {
                m_openProjectDialog = descriptor;
            }
            else if (windowTypeName == RuntimeWindowType.ToolsPanel.ToString().ToLower())
            {
                m_toolsWindow = descriptor;
            }
            else if (windowTypeName == RuntimeWindowType.SelectAssetLibrary.ToString().ToLower())
            {
                m_selectAssetLibraryDialog = descriptor;
            }
            else if (windowTypeName == RuntimeWindowType.ImportAssets.ToString().ToLower())
            {
                m_importAssetsDialog = descriptor;
            }
            else if (windowTypeName == RuntimeWindowType.About.ToString().ToLower())
            {
                m_aboutDialog = descriptor;
            }
            else if (windowTypeName == RuntimeWindowType.SelectObject.ToString().ToLower())
            {
                m_selectObjectDialog = descriptor;
            }
            else if (windowTypeName == RuntimeWindowType.SelectColor.ToString().ToLower())
            {
                m_selectColorDialog = descriptor;
            }
            else if (windowTypeName == RuntimeWindowType.SelectAnimationProperties.ToString().ToLower())
            {
                m_selectAnimationPropertiesDialog = descriptor;
            }
            else if (windowTypeName == RuntimeWindowType.SaveFile.ToString().ToLower())
            {
                m_saveFileDialog = descriptor;
            }
            else if (windowTypeName == RuntimeWindowType.OpenFile.ToString().ToLower())
            {
                m_openFileDialog = descriptor;
            }
        }
Exemplo n.º 8
0
        public Transform CreateWindow(string windowTypeName, out WindowDescriptor wd, out GameObject content, out bool isDialog)
        {
            if (DockPanel == null)
            {
                Debug.LogError("Unable to create window. m_dockPanel == null. Set m_dockPanel field");
            }

            windowTypeName = windowTypeName.ToLower();

            content = null;
            wd      = m_windowManager.GetWindowDescriptor(windowTypeName, out isDialog);
            if (wd == null)
            {
                Debug.LogWarningFormat("{0} window was not found", windowTypeName);
                return(null);
            }

            if (wd.Created >= wd.MaxWindows)
            {
                return(null);
            }
            wd.Created++;

            if (wd.ContentPrefab != null)
            {
                wd.ContentPrefab.SetActive(false);
                content      = Instantiate(wd.ContentPrefab);
                content.name = windowTypeName;

                Transform[] children = content.transform.OfType <Transform>().ToArray();
                for (int i = 0; i < children.Length; ++i)
                {
                    Transform component = children[i];
                    if (!(component is RectTransform))
                    {
                        component.gameObject.SetActive(false);
                        component.transform.SetParent(m_componentsRoot, false);
                    }
                }

                List <Transform> extraComponents = new List <Transform>();
                for (int i = 0; i < children.Length; ++i)
                {
                    if (children[i].parent == m_componentsRoot)
                    {
                        extraComponents.Add(children[i]);
                    }
                }

                m_extraComponents.Add(content.transform, extraComponents);
            }
            else
            {
                content = new GameObject();
                content.AddComponent <RectTransform>();
                content.name = "Empty Content";

                m_extraComponents.Add(content.transform, new List <Transform>());
            }

            HashSet <Transform> windows;

            if (!m_windows.TryGetValue(windowTypeName, out windows))
            {
                windows = new HashSet <Transform>();
                m_windows.Add(windowTypeName, windows);
            }

            windows.Add(content.transform);
            return(content.transform);
        }