Unity
UGUI
Render Texture
RenderTexture:Inherits from:TextureRender textures are textures that can be rendered to.They can be used to implement image based rendering effects, dynamic shadows, projectors, reflections or surveillance cameras.One typical usage of render textures is setting them as the 'target texture' property of a Camera (Camera.targetTexture), this will make a camera render into a texture instead of rendering to the screen.Keep in mind that render texture contents can become 'lost' on certain events, like loading a new level, system going to a screensaver mode, in and out of fullscreen and so on. When that happens, your existing render textures will become 'not yet created' again, you can check for that with IsCreated function.As with other 'native engine object' types, it is important to pay attention to the lifetime of any render textures and release them when you are finished using them with the Release function, as they will not be garbage collected like normal managed types.
方法提要:Layer 的使用,玩家和NPC的图标小地图渲染,实际场景的主摄像机不渲染
打开Unity,新建一个空工程,具体如下
向工厂中导入资源,并在场景中新建“Plane”和“Capsule”,并把“Capsule”分别命名为“Player”和“Enemy”,在“Player”和“Enemy”下分别再加一个“Quad”,然后如图对应添加材质和贴图,并且合理规划布局,具体如下图
选中“Player”和“Enemy”,新建一个“Human”层,并把“Player”和“Enemy”的层“Layer”都修改为“Human”,具体如下图
选中“Player”和“Enemy”下的“Quad”,新建一个“MiniMap”层,把“Quad”的层都改为“MiniMap”,具体如下图
选中“MainCamera”,去掉“Culling Mask”的“MiniMap”层,不让“MainCamera”进行渲染,具体如下图
在场景中在新建一个“Camera”可以命名为“MiniMapCamera”,把“MiniMapCamera”相机的“Projection”改为“Orthographic”正交模式,并把“MiniMapCamera”向下俯拍场景,且调整好高度,具体如下图
接着把“MiniMapCamera”的“Culling Mask”去掉“Human”层的渲染,具体如下图
到此,《Unity 小地图 之 使用UGUI实现小地图一场景布置》讲解结束,谢谢
您的支持,是我们不断坚持知识分享的动力,若帮到您,还请帮忙投票有得;若有疑问,请留言