Example #1
0
        protected override void AwakeOverride()
        {
            base.AwakeOverride();
            if (m_background == null)
            {
                if (!Editor.IsVR)
                {
                    m_background = GetComponent <Image>();
                    if (m_background == null)
                    {
                        m_background               = gameObject.AddComponent <Image>();
                        m_background.color         = new Color(0, 0, 0, 0);
                        m_background.raycastTarget = true;
                    }
                }
            }

            if (m_pointer == null)
            {
                if (Editor.IsVR)
                {
                    m_pointer = gameObject.AddComponent <VRPointer>();
                }
                else
                {
                    m_pointer = gameObject.AddComponent <Pointer>();
                }
            }

            m_rectTransform = GetComponent <RectTransform>();
            m_canvas        = GetComponentInParent <Canvas>();


            Editor.ActiveWindowChanged += OnActiveWindowChanged;

            m_index = Editor.GetIndex(WindowType);

            if (m_camera != null)
            {
                SetCullingMask();
                if (WindowType == RuntimeWindowType.SceneView)
                {
                    GLCamera glCamera = m_camera.GetComponent <GLCamera>();
                    if (!glCamera)
                    {
                        glCamera = m_camera.gameObject.AddComponent <GLCamera>();
                    }
                    glCamera.CullingMask = 1 << (Editor.CameraLayerSettings.RuntimeGraphicsLayer + m_index);
                }
            }

            Editor.RegisterWindow(this);
        }
        protected override void AwakeOverride()
        {
            base.AwakeOverride();
            if (!RenderPipelineInfo.UseRenderTextures && !ForceUseRenderTextures)
            {
                if (Camera != null)
                {
                    Image windowBackground = GetComponent <Image>();
                    if (windowBackground != null)
                    {
                        Color color = windowBackground.color;
                        color.a = 0;
                        windowBackground.color = color;
                    }

                    RenderTextureCamera renderTextureCamera = Camera.GetComponent <RenderTextureCamera>();
                    if (renderTextureCamera != null)
                    {
                        DestroyImmediate(renderTextureCamera);
                    }

                    Camera.allowMSAA = true;
                }
            }

            if (m_background == null)
            {
                if (!Editor.IsVR)
                {
                    m_background = GetComponent <Image>();
                    if (m_background == null)
                    {
                        m_background               = gameObject.AddComponent <Image>();
                        m_background.color         = new Color(0, 0, 0, 0);
                        m_background.raycastTarget = true;
                    }
                    else
                    {
                        m_background.raycastTarget = true;
                    }
                }
            }

            if (m_pointer == null)
            {
                if (Editor.IsVR)
                {
                    m_pointer = gameObject.AddComponent <VRPointer>();
                }
                else
                {
                    m_pointer = gameObject.AddComponent <Pointer>();
                }
            }

            m_rectTransform = GetComponent <RectTransform>();
            m_canvas        = GetComponentInParent <Canvas>();
            m_canvasGroup   = GetComponent <CanvasGroup>();
            if (m_canvasGroup == null)
            {
                m_canvasGroup = gameObject.AddComponent <CanvasGroup>();
            }

            if (m_canvasGroup != null)
            {
                m_canvasGroup.blocksRaycasts     = true;
                m_canvasGroup.ignoreParentGroups = true;
            }

            Editor.ActiveWindowChanged += OnActiveWindowChanged;

            m_index = Editor.GetIndex(WindowType);

            if (m_camera != null)
            {
                SetCullingMask();
                if (WindowType == RuntimeWindowType.Scene)
                {
                    GLCamera glCamera = m_camera.GetComponent <GLCamera>();
                    if (!glCamera)
                    {
                        glCamera = m_camera.gameObject.AddComponent <GLCamera>();
                    }
                    glCamera.CullingMask = 1 << (Editor.CameraLayerSettings.RuntimeGraphicsLayer + m_index);
                }
            }

            Editor.RegisterWindow(this);
        }