// Begin an automatically laid out scrollview. public static Vector2 BeginScrollView(Vector2 scrollPosition, bool alwaysShowHorizontal, bool alwaysShowVertical, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, GUIStyle background, params GUILayoutOption[] options) { GUIUtility.CheckOnGUI(); GUIScrollGroup g = (GUIScrollGroup)GUILayoutUtility.BeginLayoutGroup(background, null, typeof(GUIScrollGroup)); switch (Event.current.type) { case EventType.Layout: g.resetCoords = true; g.isVertical = true; g.stretchWidth = 1; g.stretchHeight = 1; g.verticalScrollbar = verticalScrollbar; g.horizontalScrollbar = horizontalScrollbar; g.needsVerticalScrollbar = alwaysShowVertical; g.needsHorizontalScrollbar = alwaysShowHorizontal; g.ApplyOptions(options); break; default: break; } return(GUI.BeginScrollView(g.rect, scrollPosition, new Rect(0, 0, g.clientWidth, g.clientHeight), alwaysShowHorizontal, alwaysShowVertical, horizontalScrollbar, verticalScrollbar, background)); }
// Make an auto-sized draggable window... static Rect DoWindow(int id, Rect screenRect, GUI.WindowFunction func, GUIContent content, GUIStyle style, GUILayoutOption[] options) { GUIUtility.CheckOnGUI(); LayoutedWindow lw = new LayoutedWindow(func, screenRect, content, options, style); return(GUI.Window(id, screenRect, lw.DoWindow, content, style)); }
public static void FlexibleSpace() { GUIUtility.CheckOnGUI(); GUILayoutOption gUILayoutOption = (!GUILayoutUtility.current.topLevel.isVertical) ? ExpandWidth(expand: true) : ExpandHeight(expand: true); gUILayoutOption.value = 10000; GUILayoutUtility.GetRect(0f, 0f, GUILayoutUtility.spaceStyle, gUILayoutOption); }
public static bool Prefix(int id, Rect screenRect, GUI.WindowFunction func, GUIContent content, GUIStyle style, Il2CppReferenceArray <GUILayoutOption> options, out Rect __result) { GUIUtility.CheckOnGUI(); var @object = new LayoutedWindow(func, screenRect, content, options, style); __result = GUI.Window(id, screenRect, (GUI.WindowFunction)@object.DoWindow, content, style); return(false); }
public static bool Prefix(GUIContent content, GUIStyle style, Il2CppReferenceArray <GUILayoutOption> options, ref Rect __result) { GUIUtility.CheckOnGUI(); var type = Event.current.type; if (type != EventType.Layout) { if (type != EventType.Used) { var next = GUILayoutUtility.current.topLevel.GetNext(); __result = next.rect; } else { __result = GUILayoutUtility.kDummyRect; } } else { var isHeightDependantOnWidth = style.isHeightDependantOnWidth; if (isHeightDependantOnWidth) { GUILayoutUtility.current.topLevel.Add(new GUIWordWrapSizer(style, content, options)); } else { var constraints = new Vector2(0f, 0f); if (options != null) { foreach (var guilayoutOption in options) { var type2 = guilayoutOption.type; if (type2 != GUILayoutOption.Type.maxWidth) { if (type2 == GUILayoutOption.Type.maxHeight) { constraints.y = guilayoutOption.value.Unbox <float>(); } } else { constraints.x = guilayoutOption.value.Unbox <float>(); } } } var vector = style.CalcSizeWithConstraints(content, constraints); vector.x = Mathf.Ceil(vector.x); vector.y = Mathf.Ceil(vector.y); GUILayoutUtility.current.topLevel.Add(new GUILayoutEntry(vector.x, vector.x, vector.y, vector.y, style)); } __result = GUILayoutUtility.kDummyRect; } return(false); }
private static float Scroller(Rect position, float value, float size, float leftValue, float rightValue, GUIStyle slider, GUIStyle thumb, GUIStyle leftButton, GUIStyle rightButton, bool horiz) { GUIUtility.CheckOnGUI(); int controlID = GUIUtility.GetControlID(GUI.s_SliderHash, FocusType.Passive, position); Rect position2; Rect rect; Rect rect2; if (horiz) { position2 = new Rect(position.x + leftButton.fixedWidth, position.y, position.width - leftButton.fixedWidth - rightButton.fixedWidth, position.height); rect = new Rect(position.x, position.y, leftButton.fixedWidth, position.height); rect2 = new Rect(position.xMax - rightButton.fixedWidth, position.y, rightButton.fixedWidth, position.height); } else { position2 = new Rect(position.x, position.y + leftButton.fixedHeight, position.width, position.height - leftButton.fixedHeight - rightButton.fixedHeight); rect = new Rect(position.x, position.y, position.width, leftButton.fixedHeight); rect2 = new Rect(position.x, position.yMax - rightButton.fixedHeight, position.width, rightButton.fixedHeight); } value = Slider(position2, value, size, leftValue, rightValue, slider, thumb, horiz, controlID); bool flag = Event.current.type == EventType.MouseUp; if (ScrollerRepeatButton(controlID, rect, leftButton)) { value -= 10f * ((leftValue >= rightValue) ? -1f : 1f); } if (ScrollerRepeatButton(controlID, rect2, rightButton)) { value += 10f * ((leftValue >= rightValue) ? -1f : 1f); } if (flag && Event.current.type == EventType.Used) { s_ScrollControlId = 0; } if (leftValue < rightValue) { value = Mathf.Clamp(value, leftValue, rightValue - size); } else { value = Mathf.Clamp(value, rightValue, leftValue - size); } return(value); }
public static void EndArea() { GUIUtility.CheckOnGUI(); if (Event.current.type != EventType.Used) { GUILayoutUtility.current.layoutGroups.Pop(); GUILayoutUtility.current.topLevel = (GUILayoutGroup)GUILayoutUtility.current.layoutGroups.Peek(); GUI.EndGroup(); } }
// Insert a space in the current layout group. static public void Space(float pixels) { GUIUtility.CheckOnGUI(); if (GUILayoutUtility.current.topLevel.isVertical) { GUILayoutUtility.GetRect(0, pixels, GUILayoutUtility.spaceStyle, GUILayout.Height(pixels)); } else { GUILayoutUtility.GetRect(pixels, 0, GUILayoutUtility.spaceStyle, GUILayout.Width(pixels)); } }
internal static void DrawRoundedBoxAroundLODDFoldout(int lodGroupIndex, int activeLOD) { Texture borderTexture = lodGroupIndex == activeLOD ? GUIStyles.m_BlueBorderTextureSelected.image : GUIStyles.m_BlueBorderTextureNormal.image; GUILayoutGroup g = GUILayoutUtility.BeginLayoutGroup(EditorStyles.helpBox, null, typeof(GUILayoutGroup)); g.isVertical = true; GUIUtility.CheckOnGUI(); if (Event.current.type == EventType.Repaint) { GUI.DrawTexture(g.rect, borderTexture, ScaleMode.StretchToFill, true, 1, Color.white, Vector4.one * 1, Vector4.one * 3, true); } }
public static void BeginArea(Rect screenRect, GUIContent content, GUIStyle style) { GUIUtility.CheckOnGUI(); GUILayoutGroup gUILayoutGroup = GUILayoutUtility.BeginLayoutArea(style, typeof(GUILayoutGroup)); if (Event.current.type == EventType.Layout) { gUILayoutGroup.resetCoords = true; gUILayoutGroup.minWidth = (gUILayoutGroup.maxWidth = screenRect.width); gUILayoutGroup.minHeight = (gUILayoutGroup.maxHeight = screenRect.height); gUILayoutGroup.rect = Rect.MinMaxRect(screenRect.xMin, screenRect.yMin, gUILayoutGroup.rect.xMax, gUILayoutGroup.rect.yMax); } GUI.BeginGroup(gUILayoutGroup.rect, content, style); }
// Insert a flexible space element. static public void FlexibleSpace() { GUIUtility.CheckOnGUI(); GUILayoutOption op; if (GUILayoutUtility.current.topLevel.isVertical) { op = ExpandHeight(true); } else { op = ExpandWidth(true); } op.value = 10000; GUILayoutUtility.GetRect(0, 0, GUILayoutUtility.spaceStyle, op); }
// Button used for the icon selector where an icon can be selected by pressing and dragging the // mouse cursor around to select different icons internal static bool IconButton(int id, Rect position, GUIContent content, GUIStyle style) { GUIUtility.CheckOnGUI(); switch (Event.current.GetTypeForControl(id)) { case EventType.MouseDown: // If the mouse is inside the button, we say that we're the hot control if (position.Contains(Event.current.mousePosition)) { GUIUtility.hotControl = id; Event.current.Use(); return(true); } return(false); case EventType.MouseUp: if (GUIUtility.hotControl == id) { GUIUtility.hotControl = 0; // If we got the mousedown, the mouseup is ours as well // (no matter if the click was in the button or not) Event.current.Use(); // But we only return true if the button was actually clicked return(position.Contains(Event.current.mousePosition)); } return(false); case EventType.MouseDrag: if (position.Contains(Event.current.mousePosition)) { GUIUtility.hotControl = id; Event.current.Use(); return(true); } break; case EventType.Repaint: style.Draw(position, content, id); break; } return(false); }
public static Vector2 BeginScrollView(Vector2 scrollPosition, bool alwaysShowHorizontal, bool alwaysShowVertical, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, GUIStyle background, params GUILayoutOption[] options) { GUIUtility.CheckOnGUI(); GUIScrollGroup gUIScrollGroup = (GUIScrollGroup)GUILayoutUtility.BeginLayoutGroup(background, null, typeof(GUIScrollGroup)); EventType type = Event.current.type; if (type == EventType.Layout) { gUIScrollGroup.resetCoords = true; gUIScrollGroup.isVertical = true; gUIScrollGroup.stretchWidth = 1; gUIScrollGroup.stretchHeight = 1; gUIScrollGroup.verticalScrollbar = verticalScrollbar; gUIScrollGroup.horizontalScrollbar = horizontalScrollbar; gUIScrollGroup.needsVerticalScrollbar = alwaysShowVertical; gUIScrollGroup.needsHorizontalScrollbar = alwaysShowHorizontal; gUIScrollGroup.ApplyOptions(options); } return(GUI.BeginScrollView(gUIScrollGroup.rect, scrollPosition, new Rect(0f, 0f, gUIScrollGroup.clientWidth, gUIScrollGroup.clientHeight), alwaysShowHorizontal, alwaysShowVertical, horizontalScrollbar, verticalScrollbar, background)); }