Unity中VIVE弹出UI的创建

xiaoxiao2021-02-28  115

1.创建画布,放置在层次列表中任何位置

2.将画布摄像机设置为space world.

3.在画布上创建一个脚本控制UI的显示和出现的位置.

4.UI出现位置的脚本

using System.Collections; using System.Collections.Generic; using UnityEngine; public class WebpagePosition : MonoBehaviour { public Transform eyesCamera; private RectTransform rect; void Start () { rect = this.GetComponent<RectTransform>(); rect.position = eyesCamera.position + eyesCamera.forward*2+eyesCamera.up*(-0.2f); Quaternion targetQua = eyesCamera.rotation; targetQua.x = 0f; targetQua.z = 0f; rect.rotation = targetQua; } }将Camera(eyes)拖拽到脚本中即完成!

转载请注明原文地址: https://www.6miu.com/read-48049.html

最新回复(0)