博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
U3D人物选择界面:rawimage与摄像机
阅读量:4195 次
发布时间:2019-05-26

本文共 886 字,大约阅读时间需要 2 分钟。

  在游戏中,我们通常会遇到这样的选择界面,通常人物会显示在UI层级之前,这时候我们就需要使用一点儿小技巧。

  首先,我们需要在UI中添加RawImage,大小属性自己调整,而后新建camera并照射物体,最终将camera与rawimage联系起来就行,代码如下:

using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;public class NewBehaviourScript : MonoBehaviour {    public RawImage showZombieRaw;    // Use this for initialization    void Start () {        if (gameObject.GetComponent
().targetTexture == null) { RenderTexture rt = new RenderTexture((int)showZombieRaw.GetComponent
().rect.size.x, (int)showZombieRaw.GetComponent
().rect.size.y, 16, RenderTextureFormat.Default); showZombieRaw.texture = rt; gameObject.GetComponent
().targetTexture = rt; } //} } // Update is called once per frame void Update () { }}

最终实现效果如下:

转载地址:http://nawli.baihongyu.com/

你可能感兴趣的文章
【一天一道LeetCode】#36. Valid Sudoku
查看>>
【一天一道LeetCode】#75. Sort Colors
查看>>
【一天一道LeetCode】#76. Minimum Window Substring
查看>>
【计算机网络 第五版】阅读笔记之一:概述
查看>>
【计算机网络 第五版】阅读笔记之二:物理层
查看>>
【计算机网络 第五版】阅读笔记之三:数据链路层
查看>>
【计算机网络 第五版】阅读笔记之四:网络层
查看>>
【计算机网络 第五版】阅读笔记之五:运输层
查看>>
【一天一道LeetCode】#77. Combinations
查看>>
【一天一道LeetCode】#78. Subsets
查看>>
【一天一道LeetCode】#79. Word Search
查看>>
【一天一道LeetCode】#81. Search in Rotated Sorted Array II
查看>>
【数据结构与算法】深入浅出递归和迭代的通用转换思想
查看>>
【一天一道LeetCode】#83. Remove Duplicates from Sorted List
查看>>
【一天一道LeetCode】#91. Decode Ways
查看>>
【一天一道LeetCode】#92. Reverse Linked List II
查看>>
【一天一道LeetCode】#93. Restore IP Addresses
查看>>
【一天一道LeetCode】#94. Binary Tree Inorder Traversal
查看>>
【一天一道LeetCode】#112. Path Sum
查看>>
【一天一道LeetCode】#113. Path Sum II
查看>>