如何在 ARKit 的 SCNPlane 上渲染具有透明背景的 UIView? [英] How to render a UIView with transparent background on an SCNPlane in ARKit?

查看:20
本文介绍了如何在 ARKit 的 SCNPlane 上渲染具有透明背景的 UIView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 UIView 有一个 UIColor.clear 背景.我正在从故事板实例化视图控制器.

My UIView has a UIColor.clear background. I am instantiating the View Controller from a storyboard.

当我将 SCNPlane 几何体的漫反射内容设置为视图控制器的视图时,透明背景在平面上显示为纯白色.这是我设置的方式

When I set SCNPlane geometry's diffuse contents to the viewcontroller's view, the Transparent background appears solid white on the plane. here is how I set it

let material = SCNMaterial()
material.diffuse.contents = viewController.view
planeGeometry.materials = [material]

我可以看到视图,只是背景不透明.

I can see the view, just the background is not transparent.

我看到了其他 Stack Overflow 帖子的建议,他们建议尝试这个

I saw suggestion on other Stack overflow posts where they suggested to try this

material.diffuse.contents = viewController.view.layer

这有效并且平面渲染了透明度,但随后视图不再具有交互性.

This works and the the plane renders the transparencies, but then the view is not interactive anymore.

有没有什么方法可以让我在平面上渲染视图时保持交互性和透明度?

Is there a way that I can retain the interactivity and the transparency when the view is rendered on the plane?

推荐答案

尝试设置您的视图的 isOpaque 属性为 false:

Try setting your view's isOpaque property to false:

let material = SCNMaterial()
viewController.view.isOpaque = false
material.diffuse.contents = viewController.view
planeGeometry.materials = [material]

这篇关于如何在 ARKit 的 SCNPlane 上渲染具有透明背景的 UIView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆