Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使GUI框的下角保持在原位_C#_User Interface_Unity3d - Fatal编程技术网

C# 使GUI框的下角保持在原位

C# 使GUI框的下角保持在原位,c#,user-interface,unity3d,C#,User Interface,Unity3d,如果标题难看,我很抱歉 问题是:我已经在Unity中制作了如下GUI框: 如果你在图像2上看到,那里有一个空白,我不想这样。我想要的是下角保持不变,就像图1一样,只有上角在增长,但下角保持不变 下面是一幅示例图像(取自纽厄斯的英雄): 如果您在图像1上看到,包含文本的框的下角将保留在屏幕的下角,并且如果您查看图像2并将其与图像1进行比较,则只有框的上角会增长到顶部(减去屏幕分辨率)下角保持在屏幕分辨率的下角 我有什么办法可以做到这一点吗 以下是我正在使用的代码: string textOnB

如果标题难看,我很抱歉

问题是:我已经在Unity中制作了如下GUI框:

如果你在图像2上看到,那里有一个空白,我不想这样。我想要的是下角保持不变,就像图1一样,只有上角在增长,但下角保持不变

下面是一幅示例图像(取自纽厄斯的英雄):

如果您在图像1上看到,包含文本的框的下角将保留在屏幕的下角,并且如果您查看图像2并将其与图像1进行比较,则只有框的上角会增长到顶部(减去屏幕分辨率)下角保持在屏幕分辨率的下角

我有什么办法可以做到这一点吗

以下是我正在使用的代码:

string textOnBox = "This is an example on how does the text on the box is align.\nMy Name is ....\nI am new at Unity and want to learn more about Unity to create and publish my own game using this engine.";
    GUIStyle style;
    GUIContent boxText;

    void OnGUI()
    {
        boxText = new GUIContent("" + textOnBox);

        GUI.color = new Color(0, 0, 0, 0.9f);

        style = new GUIStyle(GUI.skin.box);
        style.alignment = TextAnchor.MiddleLeft;

        Rect boxGUI = GUILayoutUtility.GetRect(boxText, "Box");

        boxGUI.x = Screen.width / 2 + 50;
        boxGUI.y = Screen.height / 2 + 200;

        GUI.Box(boxGUI, boxText, style);
    }
非常感谢你的回答!
多谢各位

可以使用样式中的fontsize来确定3行文本框的大小,以达到您可以达到的高度

style.fontSize * 3;