public static void EndScale() { if (GUIMatrices.Count == 0 || adjustedGUILayout.Count == 0) { throw new UnityException("GUIScaleUtility: You are ending more scale regions than you are beginning!"); } GUI.matrix = GUIMatrices[GUIMatrices.Count - 1]; GUIMatrices.RemoveAt(GUIMatrices.Count - 1); if (adjustedGUILayout[adjustedGUILayout.Count - 1]) { GUILayout.EndVertical(); GUILayout.EndHorizontal(); } adjustedGUILayout.RemoveAt(adjustedGUILayout.Count - 1); GUI.EndGroup(); if (compabilityMode) { if (!Application.isPlaying) { GUI.BeginClip(new Rect(0, 23, Screen.width, Screen.height - 23)); } else { GUI.BeginClip(new Rect(0, 0, Screen.width, Screen.height)); } } else { GUIScaleUtility.RestoreClips(); } }
public static Vector2 BeginScale(ref Rect rect, Vector2 zoomPivot, float zoom, bool adjustGUILayout) { Rect screenRect; if (compabilityMode) { GUI.EndGroup(); screenRect = rect; #if UNITY_EDITOR if (!Application.isPlaying) { screenRect.y += 23; } #endif } else { GUIScaleUtility.BeginNoClip(); screenRect = GUIScaleUtility.GUIToScaledSpace(rect); } rect = Scale(screenRect, screenRect.position + zoomPivot, new Vector2(zoom, zoom)); GUI.BeginGroup(rect); rect.position = Vector2.zero; Vector2 zoomPosAdjust = rect.center - screenRect.size / 2 + zoomPivot; adjustedGUILayout.Add(adjustGUILayout); if (adjustGUILayout) { GUILayout.BeginHorizontal(); GUILayout.Space(rect.center.x - screenRect.size.x + zoomPivot.x); GUILayout.BeginVertical(); GUILayout.Space(rect.center.y - screenRect.size.y + zoomPivot.y); } GUIMatrices.Add(GUI.matrix); GUIUtility.ScaleAroundPivot(new Vector2(1 / zoom, 1 / zoom), zoomPosAdjust); return(zoomPosAdjust); }
public void Show(Vector2 pos, float MinWidth = 40) { popup.Show(GUIScaleUtility.GUIToScreenSpace(pos), MinWidth); }
public void ShowAsContext() { popup.Show(GUIScaleUtility.GUIToScreenSpace(Event.current.mousePosition)); }