Exemplo n.º 1
0
    internal void RecreateRenderTarget()
    {
        RecreateViewTexture(Width, Height);
        View.SetNewRenderTarget(
            ViewTexture.GetNativeTexturePtr(), DepthTexture.GetNativeTexturePtr(),
            (uint)Width, (uint)Height, 1);

        CoherentUIGTRenderEvents.SendRenderEvent(CoherentRenderEventType.SetNewRenderTarget,
                                                 View.GetId());
    }
Exemplo n.º 2
0
    public void Layout()
    {
        // Layout is called on CoherentUIGTSystem component Update
        // because UISystem.Advance() should happen before View.Layout()
        var view = View;

        if (!enabled || view == null)
        {
            return;
        }

        if ((!ViewTexture.IsCreated() || !DepthTexture.IsCreated()) &&
            Screen.fullScreen == m_WasLastFrameFullscreen)
        {
            // Make sure that we don't call RecreateRenderTarget twice when transitioning from
            // Fullscreen to Windowed mode and vice versa; calling RecreateRenderTarget second
            // time sets wrong render texture target that leads to missing UI on the screen

            Debug.Log("[Debug] No render texture present. Recreating it");
            RecreateRenderTarget();
        }
        m_WasLastFrameFullscreen = Screen.fullScreen;

        if (m_UseCameraDimensions)
        {
            int width  = 0;
            int height = 0;
            if (GetCamDimensions(out width, out height))
            {
                if (width != m_Width || height != m_Height)
                {
                    Resize(width, height);
                }
            }
        }

        if (ViewRenderer != null)
        {
            view.Layout();
        }
    }
Exemplo n.º 3
0
    IEnumerator SendCreateView()
    {
        if (m_IsCoroutineStarted)
        {
            yield break;
        }

        m_IsCoroutineStarted = true;

        if (string.IsNullOrEmpty(Page))
        {
            throw new System.ApplicationException("The Page of a view must not be null or empty.");
        }

        if (ResourceHandlerFactoryFunc != null)
        {
            m_ResourceHandler = ResourceHandlerFactoryFunc();
        }

        if (m_ResourceHandler == null)
        {
            Debug.LogWarning("Unable to create file handler using factory function! Falling back to default handler.");
            m_ResourceHandler = new UnityGTResourceHandler();
        }

        ViewLoadPolicy policy = ViewLoadPolicy.VLP_UseCacheOrLoad;

                #if UNITY_EDITOR
        m_ResourcesInUse  = new HashSet <string>();
        m_ResourceHandler = new UnityGTResourceHandlerDecorator(m_ResourceHandler, this);

        if (AutoRefresh)
        {
            policy = ViewLoadPolicy.VLP_IgnoreCache;
        }
                #endif

        var viewInfo = new ViewInfo();
        viewInfo.Width                      = (uint)this.m_Width;
        viewInfo.Height                     = (uint)this.m_Height;
        viewInfo.IsTransparent              = this.m_IsTransparent;
        viewInfo.ViewListenerInstance       = m_Listener;
        viewInfo.ResourceHandlerInstance    = m_ResourceHandler;
        viewInfo.ClickThroughAlphaThreshold = ClickThroughThreshold;

        if (string.IsNullOrEmpty(InitialScript))
        {
            View = m_UISystem.UISystem.CreateView(viewInfo, Page, policy);
        }
        else
        {
            View = m_UISystem.UISystem.CreateView(viewInfo, Page, InitialScript, policy);
        }

        RecreateViewTexture(m_Width, m_Height);

        View.SetNewRenderTarget(ViewTexture.GetNativeTexturePtr(),
                                DepthTexture.GetNativeTexturePtr(),
                                (uint)m_Width, (uint)m_Height, 1);

        CoherentUIGTRenderEvents.SendRenderEvent(CoherentRenderEventType.CreateViewRenderer,
                                                 View.GetId());

        while (ViewRenderer == null)
        {
            ViewRenderer = View.GetViewRenderer();
            yield return(null);
        }

        AddViewRendererComponent();
    }