1
我是Unity3D的初學者,並且都與遊戲開發相關。最近,我試圖做一個簡單的程序,以在HoloLens中實現它。我們的目標是讓3D文字(「_text」)在相機移動的方向上移動,這非常有效。然而,當我將我的頭部(與HoloLens相同)(+/-)90度移動時,我無法閱讀文本,因爲我沒有面對文本,180度時我看到了我的3d文本翻轉。如果有人能幫助我,我將不勝感激。 :)在Unity中使用相機進行3D文本旋轉
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TextManager : MonoBehaviour {
public GameObject _text;
public TextMesh _startText;
// Use this for initialization
void Start() {
if (_text == null) _text = GameObject.Find("StartText");
if (_startText == null) _startText = GameObject.Find("StartText").GetComponent<TextMesh>();
}
// Update is called once per frame
void Update() {
if (_text.activeSelf)
{
var camPos = Camera.main.transform.position + Camera.main.transform.forward;
_text.transform.position = camPos;
_text.transform.localScale = Vector3.one * 0.025f;
}
else
{
Debug.Log("deactive _startText");
}
}
}