Skip to content
This repository has been archived by the owner on Sep 14, 2021. It is now read-only.

Disabling background #81

Closed
iBicha opened this issue Jan 19, 2018 · 2 comments
Closed

Disabling background #81

iBicha opened this issue Jan 19, 2018 · 2 comments

Comments

@iBicha
Copy link

iBicha commented Jan 19, 2018

currently disabling ARCoreBackgroundRenderer does not disable background rendering for me.
The way to go is to set the ARBackgroundRenderer.mode to ARRenderMode.MaterialAsBackground when we want to enable it, and to ARRenderMode.StandardBackground when we want to disable it. It's a bad idea to do a null check on it every frame anyway, as it is unnecessary.

A piece of code I'm currently using as a hack, in another script on the camera:

private ARBackgroundRenderer m_BackgroundRenderer;
private ARCoreBackgroundRenderer m_ARCoreBackgroundRenderer;
private ARBackgroundRenderer BackgroundRenderer
{
    get
    {
        if(m_BackgroundRenderer == null || m_ARCoreBackgroundRenderer == null)
        {
            m_ARCoreBackgroundRenderer = GetComponent<ARCoreBackgroundRenderer>();
            if (m_ARCoreBackgroundRenderer != null)
            {
                System.Reflection.FieldInfo m_BackgroundRendererField = typeof(ARCoreBackgroundRenderer).GetField("m_BackgroundRenderer", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                if (m_BackgroundRendererField != null)
                {
                    m_BackgroundRenderer = (ARBackgroundRenderer)m_BackgroundRendererField.GetValue(m_ARCoreBackgroundRenderer);
                }
            }
        }
        return m_BackgroundRenderer;
    }
}

And then:

BackgroundRenderer.mode = enabled ? ARRenderMode.MaterialAsBackground : ARRenderMode.StandardBackground;
@chaosemer
Copy link
Contributor

Thanks for the bug report, I've added it to our internal tracker.

@pablisho
Copy link
Contributor

Hi, this issue has been fixed in ARCore Unity SDK v1.1.0. Feel free to reopen if you still experience the issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants