
Unity3d Sandboxさんの所でGUITextureの回転についての解説を見かけたので早速、試してみました。
Unity3d Sandbox: GUITexture 回転問題
http://zi-su.blogspot.com/2011/05/guitexture.html?spref=tw
プログラムはこんな感じ。
【GUIScript.js】
var playerObj : GameObject;
var aTexture : Texture;
function OnGUI () {
var pivotPoint : Vector2 = Vector2(35, 35);
var angleY : float = playerObj.transform.localEulerAngles.y;
GUIUtility.RotateAroundPivot(angleY, pivotPoint);
GUI.DrawTexture(Rect(5, 5, 60, 60), aTexture);
}今回のサンプルはこちらで試せます。一度画面をクリックしてフォーカスを当ててからキー入力をする様にして下さい。左上のアイコンがキャラクターの向きに合わせて回転します。ソースファイルはこちら。
関連情報
Unity Script Reference – GUIUtility.RotateAroundPivot
http://unity3d.com/support/documentation/ScriptReference/GUIUtility.RotateAroundPivot.html