Unity中Skybox上的悬停菜单 [英] Hover Menu on Skybox in Unity

查看:132
本文介绍了Unity中Skybox上的悬停菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个关于VR/AR交互的问题.

I have a question about a VR/AR-interaction I would like to create.

我想拥有一个图像,它可以充当天空盒,以在空中提供空中视角,并允许用户将鼠标悬停在图像的一部分上,以显示一个小面板,其中包含正在查看的对象的描述.

I want to have an image that acts as a skybox to give an aerial perspective on a landscape and allow users to hover over a part of the image to show a small panel with a description of the object they are looking at.

例如,如果我有一个包含城市景观的天空盒,并希望允许用户将鼠标悬停在建筑物上,并有一个弹出交互来显示建筑物的名称,那么做这件事的最佳策略是什么?

For example, if I have a skybox of a cityscape and wanted to allow users to hover over a building and have a popup interaction displaying the name of the building, what would be the best strategy to do this?

我已经创建了天空盒,但是在尝试在特定对象上添加按钮时遇到了透视问题.

I have the skybox created but have run into perspective issues when trying to add a button over a specific object.

这种方法是否有可能?或者我需要带纹理的景观?

Is this possible with this approach or would I need a textured landscape?

推荐答案

我们通常使用广告牌(始终面向摄像机的图像)在立方体或球形天窗顶部创建热点.我们的纸板演示应用

We usually use billboards (images that always face the camera) to create hotspots on top of either cubic or spherical skyboxes. This is illustrated here in our cardboard demo app

通常只放置信息文本或弹出窗口之类的东西,我只是:

Often to place items like info text or popups, I just:

  • 将内容与一个空的GameObject关联
  • 将内容偏移到所需的距离(沿z轴)
  • 旋转父级以将内容放置在需要显示的位置

在GearVR上,由于用户/摄像头始终位于中央,因此上面就像有一个广告牌.

On GearVR, since the user/camera is always in the center the above is like having a billboard.

热点/按钮上装有对撞机,您可以在Late Update上使用相机位置&旋转以确定用户是否将鼠标悬停(注视)给定的火锅.入门两个有用的类是Camera ScreenPointToRay

The hotspots/buttons have a collider attached and you can shoot a ray, on Late Update, with the camera position & rotation to determine if the user is hovering (looking at) a given hotpot. Two helpful classes to get you started are Camera ScreenPointToRay and Physics.RayCast

要在天空盒中精确剪裁内容(例如突出显示特定建筑物),我们通常使用基于立方体贴图的天空盒并在Photoshop中进行遮罩/后处理.然后,我们将图像统一放置在相应背景天窗面板的顶部,并根据需要打开/关闭它们.为了简化在Unity中的排列,我通常使用一个自定义天空盒",它基本上是6个方形面朝上.

To do precise cutouts of content in a skybox (like highlighting a specific building) we usually use a cubemap based skybox and do the masking/post-processing in Photoshop. Then we layer the images top of the corresponding background skybox panel in unity and turn them on/off as needed. To simplify lining things up in Unity, I usually use a "custom skybox" which is basically 6 quads facing in.

hth.

这篇关于Unity中Skybox上的悬停菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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