
Unity3D游戏开发之画中画小地图.docx
10页Unity3d 中使用摄像机制作实时显示小地图,以之前的 tank 为例开始制作之前场景中物体如图开始制作,步骤 1:新建一个 camera 及一个 plane对齐位置,将 camera 改名为camera_UI旋转 plane,使之在 camera_UI 中显示为竖直状态效果如下图:其中,camera_UI 及 plane 设置如图position 位置,在 tank 前方并在视野范围内能看到即可步骤 2:为场景中物体添加 Layer,以保证后面步骤中的 camera 正确显示分别为 terrain 及 UI分别选中 terrain 及 UI,调整 inspector 窗口的 Layer,设置terrain 的 Layer 为 terrain,plane 的 Layer 为 UI此时场景中有两个 camera,game 窗口中的显示会出现混乱那么此时需要调整camera 的 Culling Mask步骤 3:调整 camera 的 Culling Mask将 tank 下面的 camera 的 Culling Mask 属性更改,此时为选中 everything 状态,点击 UI 选项,使其不选中 UI。
设置 camera_UI 的 Culling Mask 只选中 UI,同时,将 camera_UI 的 Clear Flags 改为 Don‘t Clear文章出处 【狗刨学习网】此时,即可正确显示出地形、坦克及 planeplane 将用作实时显示地图步骤 4:再新建一个 camera,改名为 camera_map,此 camera 将用作显示地图的 camera选中 camera_map,在 inspector 中找到 Target Texture,此时为空在 project 界面新建一个 Render Texture,出现一个 New Render Texture将 New Render Texture 赋给 camera_map 的 Target Texture,此时camera_map 所照摄到的范围即 New Render Texture 的显示步骤 5:回到 plane,为 plane 添加一个 material,Shader 类型为 Self—Illumin/VertexLit(即自发光) ,选择 Base,为 Base 赋上 New Render Texture此时,game 窗口中显示如图:此时已完成的差不多了,但是发现右上角的小地图是倒的,对 camera_map 调节,旋转使小地图变成正的。
若在运行过程中,小地图会被树挡住,则选中 Camera_UI 调节inspector 面板中 Camera 下的 Clipping Planes 的 Near 属性即可至此,小地图实时显示制作完成本文来源于狗刨学习网。












