本文整理汇总了C#中GUIText.GetScreenRect方法的典型用法代码示例。如果您正苦于以下问题:C# GUIText.GetScreenRect方法的具体用法?C# GUIText.GetScreenRect怎么用?C# GUIText.GetScreenRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GUIText
的用法示例。
在下文中一共展示了GUIText.GetScreenRect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FormatGuiTextArea
public static Rect FormatGuiTextArea(GUIText guiText)
{
string[] words = guiText.text.Split(' ');
string result = "";
Rect textArea = new Rect();
for(int i = 0; i < words.Length; i++)
{
guiText.text = (result + words[i] + "\n");
textArea = guiText.GetScreenRect();
result += (words[i] + "\n");
}
return textArea;
}
示例2: BuildCreateMenu
//.........这里部分代码省略.........
settingsTitle = settingsTitleObject.AddComponent<GUIText>();
fireTitle = fireTitleObject.AddComponent<GUIText>();
plusTitle = plusTitleObject.AddComponent<GUIText>();
saveTitle = saveTitleObject.AddComponent<GUIText>();
settingsTitle.text = "SETTINGS";
fireTitle.text = "FIRE";
plusTitle.text = "BACKGROUND";
saveTitle.text = "SAVE";
textList.AddMany(settingsTitle, fireTitle, plusTitle, saveTitle);
//Background
backgroundImage = Resources.Load("Backgrounds/MenuBackgrounds/Yellow") as Texture2D;
backgroundTexture.texture = backgroundImage;
//Scale
float xSize = settingsIconSprite.bounds.size.x;
float ySize = settingsIconSprite.bounds.size.y;
float width;
float height;
if (screenDPI > 0)
{
width = 76 * screenDPI;
height = 86 * screenDPI;
}
else
{
width = 76;
height = 86;
}
float worldwidth = (camera.orthographicSize * 2 / Screen.height * width) / xSize;
float worldHeight = (camera.orthographicSize * 2 / Screen.height * height) / ySize;
settingsIcon.transform.localScale = new Vector3(worldwidth, worldHeight, 1);
plusIcon.transform.localScale = new Vector3(worldwidth, worldHeight, 1);
fireIcon.transform.localScale = new Vector3(worldwidth, worldHeight, 1);
backIcon.transform.localScale = new Vector3(worldwidth, worldHeight, 1);
saveIcon.transform.localScale = new Vector3(worldwidth, worldHeight, 1);
//position
float x = camera.ScreenToWorldPoint(new Vector3((Screen.width / 2), 0, 0)).x;
float y = camera.ScreenToWorldPoint(new Vector3(0, 50, 0)).y;
Vector3 position = new Vector3(x, y, -1);
//Left 2
plusIcon.transform.position = new Vector3(position.x - (plusIconSprite.bounds.size.x * 1.1f * 2) * settingsIcon.transform.localScale.x, position.y + (plusIconSprite.bounds.size.y / 2), 1);
//Left 1
fireIcon.transform.position = new Vector3(position.x - (fireIconSprite.bounds.size.x * 1.1f) * settingsIcon.transform.localScale.x, position.y + (fireIconSprite.bounds.size.y / 2), 1);
//Midle
settingsIcon.transform.position = new Vector3(position.x, position.y + (settingsIconSprite.bounds.size.y / 2), 1);
//Right 1
saveIcon.transform.position = new Vector3(position.x + (saveIconSprite.bounds.size.x * 1.1f) * settingsIcon.transform.localScale.x, position.y + (saveIconSprite.bounds.size.y / 2), 1);
//Right 2
backIcon.transform.position = new Vector3(position.x + (backIconSprite.bounds.size.x * 1.1f * 2) * settingsIcon.transform.localScale.x, position.y + (backIconSprite.bounds.size.y / 2), 1);
plusTitle.pixelOffset = new Vector2(50, (Screen.height - 65));
settingsTitle.pixelOffset = new Vector2(50, (Screen.height - 132));
fireTitle.pixelOffset = new Vector2(50, (Screen.height - 200));
saveTitle.pixelOffset = new Vector2(50, (Screen.height - 265));
foreach (GUIText item in textList)
{
item.anchor = TextAnchor.MiddleLeft;
item.color = Color.black;
item.font = menuFont;
item.fontStyle = FontStyle.Normal;
item.fontSize = fontSize;
}
//Rect
//PlusIcon
plusTextRect = new Rect(50,
(Screen.height - plusTitle.GetScreenRect().yMax + 14),
plusTitle.GetScreenRect().width,
fontSize - 20);
//FireIcon
fireTextRect = new Rect(50,
(Screen.height - fireTitle.GetScreenRect().yMax + 14),
fireTitle.GetScreenRect().width,
fontSize - 20);
//SettingsIcon
settingsTextRect = new Rect(50,
(Screen.height - settingsTitle.GetScreenRect().yMax + 14),
settingsTitle.GetScreenRect().width,
fontSize - 20);
//SaveIcon
saveTextRect = new Rect(50,
(Screen.height - saveTitle.GetScreenRect().yMax + 14),
saveTitle.GetScreenRect().width,
fontSize - 20);
//Left Top Width Height
#endregion
}