[英]Unity3D Rotate only image in button
我正在尋找一種無需旋轉文本即可旋轉按鈕圖像的方法。 我試圖像這樣修復文本的旋轉:
transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, camera.transform.eulerAngles.y + 90); // Rotation of the whole button
GetComponentInChildren<Text>().transform.localEulerAngles = Vector3.zero; // Lock rotation of the text
...可以,但是問題是文本位置隨圖像一起移動,就像它固定了一樣。
我在互聯網上進行搜索,但未找到相同的案例。 感謝幫助 !
由於您的文字是您正在旋轉的按鈕GameObject
的子代,因此它也會受到影響。 與其嘗試反映旋轉效果,不如使圖像成為按鈕的子元素,而僅旋轉該Transform
。
button `GameObject`
— image (rotate this)
— text `Text`
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.