版本:Unity 6 (6000.0)
语言英语
  • C#

GUILayout.EndScrollView

提出更改建议

成功!

感谢您帮助我们改进 Unity 文档的质量。尽管我们无法接受所有提交,但我们确实会阅读用户提出的每条更改建议,并在适用时进行更新。

关闭

提交失败

由于某些原因,您提出的更改建议无法提交。请在 <a>几分钟后</a> 再试一次。感谢您花时间帮助我们改进 Unity 文档的质量。

关闭

取消

声明

public static void EndScrollView();

说明

结束通过调用 BeginScrollView 开始的滚动视图。

其他资源:GUILayout.BeginScrollView


游戏视图中的滚动视图...

using UnityEngine;

public class ExampleScript : MonoBehaviour { // The variable to control where the scrollview 'looks' into its child elements. Vector2 scrollPosition;

// The string to display inside the scrollview. 2 buttons below add & clear this string. string longString = "This is a long-ish string";

void OnGUI() { // Begin a scroll view. All rects are calculated automatically - // it will use up any available screen space and make sure contents flow correctly. // This is kept small with the last two parameters to force scrollbars to appear. scrollPosition = GUILayout.BeginScrollView( scrollPosition, GUILayout.Width(100), GUILayout.Height(100));

// We just add a single label to go inside the scroll view. Note how the // scrollbars will work correctly with wordwrap. GUILayout.Label(longString);

// Add a button to clear the string. This is inside the scroll area, so it // will be scrolled as well. Note how the button becomes narrower to make room // for the vertical scrollbar if (GUILayout.Button("Clear")) longString = "";

// End the scrollview we began above. GUILayout.EndScrollView();

// Now we add a button outside the scrollview - this will be shown below // the scrolling area. if (GUILayout.Button("Add More Text")) longString += "\nHere is another line"; } }