Unity - 如何在屏幕覆盖画布上方显示世界空间画布? [英] Unity - how to show world space canvas above screen overlay canvas?

查看:166
本文介绍了Unity - 如何在屏幕覆盖画布上方显示世界空间画布?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,基本上我有一个世界空间画布(目前使用不同的相机)和一个屏幕空间画布.在屏幕空间画布中,我有一个来自平面资产商店的模糊材料,它仅适用于屏幕空间.

我需要做一个切换,在那里我仍然有模糊的背景和返回的按钮,但最重要的是我有我的世界空间画布(下面的文本"对象):

在第二个摄像头上将清除标志设置为 none 可以让我看到第一个摄像头看到的内容,但看不到它的画布.这里是屏幕捕获第一台相机画布的最佳选择吗?

或者有什么方法可以不让屏幕空间画布挡住世界空间?

解决方案

所以如果我理解正确的话,你有 2 个摄像头,比方说:

  • MainCamera:用于显示 3D 内容
  • ScreenSpaceCamera:用于仅显示该屏幕空间平面".

而您想要的是:始终在 ScreenSpace 内容之上播放 3D 内容,对吗?

<小时>

所以你可以做的是创建一个特殊的

  • ScreenSpaceCamera -> Camera:

    • Depth = -1(所以它被绘制在深度级别 0 之后)
    • ClearFlags = 无(或任何你想要的)
    • CullingMask = only ScreenSpace

  • <小时>

    正如您现在看到的,3D 内容 (RedImage) 始终绘制在 ScreenSpace(白色)之上.

    <小时>

    注意:如果您希望能够打开和关闭屏幕空间,您需要一个额外的相机来实际清除图像!正如您在 Camera Preview 中看到的,相机的缓冲区没有被清除"(因为我们已经告诉过它).

    因此,如果您禁用 Screenspace,您将在预览框中看到您看到的内容!-> 不好^^

    我会简单地添加第 3 个摄像头,例如BackgroundCamera 作为 MainCamera 的孩子(所以它会自动正确移动)并给它

    • Depth = -2(所以在 ScreenSpace 后面)
    • ClearFlags = 例如SkyBox
    • CullingMask = 没有(所以你真的只在这里渲染背景)
    <小时>

    如果您有更复杂的想法,例如

    • ontop UI(深度 0)
    • 屏幕空间(深度 -1)
    • 其他 3D 内容
      让那些由 ScreenSpaceCamera 代替.因此,如果您停用模糊画布,它们将正常显示,否则会变得模糊.
    • 背景(深度 -2)

    只需使用 4 个摄像头、深度和不同层扩展示例.

    Ok, basically I have a world space canvas (that currently uses a different camera) and a screen space canvas. In the screen space canvas I have a blur material from the asset store on a plane, which only works in screen space.

    I need to do a switch where I still have that blurred background and the button to get back, but on top I have my world space canvas (the "text" objects below):

    Setting clear flags to none on the second camera allows me to see what the first camera sees, but not its canvas. Is the best option here to screen capture the first camera's canvas?

    Or is there a way to not make the screen space canvas block the world space?

    解决方案

    So if I understand you correctly you have 2 Cameras let's say:

    • MainCamera: for displaying 3D content
    • ScreenSpaceCamera: for only displaying that Screenspace "plane".

    and what you want is: Allways didplay the 3D content on top of the ScreenSpace content, right?


    So what you can do is creating a special Layer e.g. ScreenSpace and than

    • MainCamera -> Camera:

      • Depth = 0 (higher value means drawn on top)
      • ClearFlags = DepthOnly
      • CullingMask = Everything except ScreenSpace

    • ScreenSpaceCamera -> Camera:

      • Depth = -1 (so it is drawn behind depth level 0)
      • ClearFlags = Nothing (or whatever you want)
      • CullingMask = only ScreenSpace


    As you can see now the 3D content (RedImage) is always drawn on top of the ScreenSpace (white).


    Note: In case you want to be able to switch that Screenspace on and off you need an additional Camera that actually clears the image! As you can see in the Camera Preview that camera's buffer is not "cleared" (because we told it so).

    So if you would disable the Screenspace you would get what you see in the preview box! -> not good ^^

    I would simply add a 3th camera e.g. BackgroundCamera as child of the MainCamera (so it is automatically moved correctly) and give it

    • Depth = -2 (so behind the ScreenSpace)
    • ClearFlags = e.g. SkyBox
    • CullingMask = Nothing (so you really only render the background here)

    If you have something more complex in mind like e.g.

    • ontop UI (depth 0)
    • ScreenSpace (depth -1)
    • other 3D content
      let those be rendered by the ScreenSpaceCamera instead. So if you diactivate the Blurr Canvas they are displayed normal, otherwise blurred.
    • Background (depth -2)

    simply extend the example with 4 Cameras, Depths and different Layers.

    这篇关于Unity - 如何在屏幕覆盖画布上方显示世界空间画布?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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