2

Unity3Dの標準GUIを使用しています。

GUI 要素の画面位置を取得するにはどうすればよいですか?

4

3 に答える 3

0

これを試して:

var positionGui : Vector2;
positionGui = Vector2 (guiElement.transform.position.x * Screen.width, guiElement.transform.position.y * Screen.height);
于 2013-07-03T09:50:53.210 に答える
0

あなたはこのようなことをすることができます

public static Rect screenRect
    (float tx,
     float ty,
     float tw,
     float th) 
{
    float x1 = tx * Screen.width;
    float y1 = ty * Screen.height;     
    float sw = tw * Screen.width;
    float sh = th * Screen.height;
    return new Rect(x1,y1,sw,sh);
}
public void OnGUI()
{   


  if (GUI.Button(screenRect(0.4f, 0.6f, 0.2f, 0.1f), "TRY AGAIN")) 

 {  
  Application.LoadLevel(0);

 }

print ("button position + framesize"+screenRect(0.4f, 0.6f, 0.2f, 0.1f));

}
于 2013-07-03T11:23:58.517 に答える