Esempio n. 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;
                    }
                    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);
        }
Esempio n. 2
0
        protected override void AwakeOverride()
        {
            base.AwakeOverride();
            if (Camera != null)
            {
                Image windowBackground = GetComponent <Image>();
                if (windowBackground != null)
                {
                    Color color = windowBackground.color;
                    color.a = 0;
                    windowBackground.color = color;
                }

                if (RenderTextureUsage == RenderTextureUsage.Off || RenderTextureUsage == RenderTextureUsage.UsePipelineSettings && !RenderPipelineInfo.UseRenderTextures)
                {
                    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;

            if (WindowType != RuntimeWindowType.Custom)
            {
                m_index = Editor.GetIndex(WindowType);
            }
            else
            {
                m_index = 0;
            }

            if (m_camera != null)
            {
                SetCullingMask();
                if (WindowType == RuntimeWindowType.Scene)
                {
                    RegisterGraphicsCamera();
                }
                CreateGraphicsCamera();
            }

            Editor.RegisterWindow(this);
        }