Created
August 27, 2012 11:59
-
-
Save nakamura001/3487838 to your computer and use it in GitHub Desktop.
[Unity]テキストのRect情報取得
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class TestGUI : MonoBehaviour { | |
private string txt = "test"; | |
public GUIText guiText; | |
public GUIText guiTextInfo; | |
public GUITexture guiTextureBg; | |
void OnGUI () { | |
txt = GUI.TextField(new Rect(5, 5, 200, 20), txt); | |
guiText.text = txt; | |
guiTextInfo.text = guiText.GetScreenRect().ToString(); | |
Rect rcGuiText = guiText.GetScreenRect(); | |
Rect rc = rcGuiText; | |
rc.x += -Screen.width*.5f; | |
rc.y -= Screen.height*.5f; | |
guiTextureBg.pixelInset = rc; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment