コード例 #1
0
    private void SetupRenderCameraForAR()
    {
#if USES_AR_KIT
        if (mainCamera.GetComponent <UnityARVideo> ())
        {
            renderCam.clearFlags = CameraClearFlags.SolidColor;
            ARKitCameraRender component = renderCam.gameObject.AddComponent <ARKitCameraRender> ();
            component.m_ClearMaterial = mainCamera.GetComponent <UnityARVideo> ().m_ClearMaterial;
        }
#endif


#if USES_AR_CORE
        if (mainCamera.GetComponent <GoogleARCore.ARCoreBackgroundRenderer> ())
        {
            renderCam.clearFlags = CameraClearFlags.SolidColor;
            GoogleARCore.ARCoreBackgroundRenderer component = renderCam.gameObject.AddComponent <GoogleARCore.ARCoreBackgroundRenderer> ();
            component.BackgroundMaterial = mainCamera.GetComponent <GoogleARCore.ARCoreBackgroundRenderer> ().BackgroundMaterial;

            // This sucks, the first enabling fails automatically because there isn't a background material.  By doing this we still
            // get an error on the log, but it at least works.. :/
            component.enabled = false;
            component.enabled = true;
        }
#endif

#if USES_AR_FOUNDATION
        if (mainCamera.GetComponent <ARCameraBackground>())
        {
            ARCameraBackground component = renderCam.gameObject.AddComponent <ARCameraBackground>();
        }
#endif
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        if (orientInfoText)
        {
            orientInfoText.text = Screen.orientation.ToString();
        }

        if (backgroundMat == null)
        {
            arCodeRenderer = FindObjectOfType <GoogleARCore.ARCoreBackgroundRenderer>();

            if (arCodeRenderer)
            {
                backgroundMat = arCodeRenderer.BackgroundMaterial;
            }
        }

        if (backRT == null && backTextureImage)
        {
            RectTransform imageRect = backTextureImage.rectTransform;
            backRT = new RenderTexture((int)imageRect.rect.width, (int)imageRect.rect.height, 0);
        }

        if (backgroundMat && backRT)
        {
            Graphics.Blit(null, backRT, backgroundMat);
        }

        if (backTextureImage)
        {
            //backTextureImage.texture = Frame.CameraImage.Texture;
            backTextureImage.texture = backRT;
        }
    }
コード例 #3
0
 // Start is called before the first frame update
 void Start()
 {
     backgroundRenderer = cam.GetComponent <ARCoreBackgroundRenderer>();
     FaceAttachment     = faceList[activeFaceIndex];
     changeFace(0);
 }