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

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

问题描述

好吧,基本上,我有一个世界空间画布(当前使用其他相机)和一个屏幕空间画布.在屏幕空间画布中,我有飞机上资产存储中的模糊材料,该材料只能在屏幕空间中使用.

我需要进行切换,在该背景下我仍然具有模糊的背景和返回的按钮,但是最上面的是我的世界空间画布(下面的文本"对象):

在第二台摄像机上将clear标志设置为none时,我只能看到第一台摄像机看到的内容,而不能看到其画布.这里是捕获第一台相机的画布的最佳选择吗?

还是有一种方法不使屏幕空间画布阻挡世界空间?

解决方案

因此,如果我对您的理解正确,那么您有2台摄像机,例如:

  • MainCamera :用于显示3D内容
  • ScreenSpaceCamera :仅用于显示该Screenspace平面".

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


因此,您可以做的是创建一个特殊的

  • ScreenSpaceCamera -> Camera :

    • 深度 = -1(因此被绘制在深度级别0后面)
    • ClearFlags =没什么(或任何您想要的东西)
    • CullingMask =仅 ScreenSpace


  • 您现在可以看到,3D内容(RedImage)始终绘制在ScreenSpace(白色)的顶部.


    注意:如果您希望能够打开和关闭该 Screenspace ,则需要一个附加的Camera来真正清除图像!正如您在 Camera Preview 中看到的那样,未清除"相机的缓冲区(因为我们已经这样告知).

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

    我只需添加第三个摄像头,例如 BackgroundCamera 作为 MainCamera 的子级(因此它会自动正确移动)并提供

    • 深度 = -2(因此位于ScreenSpace后面)
    • ClearFlags =例如 SkyBox
    • CullingMask =没什么(所以您实际上只在此处渲染背景)

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

    • 顶部用户界面(深度为0)
    • ScreenSpace(深度-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天全站免登陆