当前位置: 首页>>代码示例>>C#>>正文


C# GUIText.GetScreenRect方法代码示例

本文整理汇总了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;
    }
开发者ID:grbarr,项目名称:burgermaker9000,代码行数:14,代码来源:TextFormatter.cs

示例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
    }
开发者ID:Cryslo,项目名称:EMSRisicoStage,代码行数:101,代码来源:BuildMenu.cs


注:本文中的GUIText.GetScreenRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。