public Draw ( |
||
position | ||
content | ||
isHover | bool | |
isActive | bool | |
on | bool | |
hasKeyboardFocus | bool | |
return | void |
public virtual void OnPreviewGUI(Rect r, GUIStyle background) { if (Event.current.type == EventType.Repaint) { background.Draw(r, false, false, false, false); } }
public override void OnPreviewGUI(Rect r, GUIStyle background) { if (Event.current.type == EventType.Repaint) { background.Draw(r, false, false, false, false); } MovieTexture target = base.target as MovieTexture; float num = Mathf.Min(Mathf.Min((float) (r.width / ((float) target.width)), (float) (r.height / ((float) target.height))), 1f); Rect viewRect = new Rect(r.x, r.y, target.width * num, target.height * num); PreviewGUI.BeginScrollView(r, base.m_Pos, viewRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb"); EditorGUI.DrawPreviewTexture(viewRect, target, null, ScaleMode.StretchToFill); base.m_Pos = PreviewGUI.EndScrollView(); if (target.isPlaying) { GUIView.current.Repaint(); } if (Application.isPlaying) { if (target.isPlaying) { EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10f, r.width, 20f), "Can't pause preview when in play mode"); } else { EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10f, r.width, 20f), "Can't start preview when in play mode"); } } }
private static bool DoRepeatButton(Rect position, GUIContent content, GUIStyle style, FocusType focusType) { int controlID = GUIUtility.GetControlID(EditorGUIExt.repeatButtonHash, focusType, position); EventType typeForControl = Event.current.GetTypeForControl(controlID); if (typeForControl == EventType.MouseDown) { if (position.Contains(Event.current.mousePosition)) { GUIUtility.hotControl = controlID; Event.current.Use(); } return false; } if (typeForControl != EventType.MouseUp) { if (typeForControl != EventType.Repaint) { return false; } style.Draw(position, content, controlID); return controlID == GUIUtility.hotControl && position.Contains(Event.current.mousePosition); } else { if (GUIUtility.hotControl == controlID) { GUIUtility.hotControl = 0; Event.current.Use(); return position.Contains(Event.current.mousePosition); } return false; } }
private static bool DoRepeatButton(Rect position, GUIContent content, GUIStyle style, FocusType focusType) { int controlId = GUIUtility.GetControlID(EditorGUIExt.repeatButtonHash, focusType, position); switch (Event.current.GetTypeForControl(controlId)) { case EventType.MouseDown: if (position.Contains(Event.current.mousePosition)) { GUIUtility.hotControl = controlId; Event.current.Use(); } return false; case EventType.MouseUp: if (GUIUtility.hotControl != controlId) return false; GUIUtility.hotControl = 0; Event.current.Use(); return position.Contains(Event.current.mousePosition); case EventType.Repaint: style.Draw(position, content, controlId); if (controlId == GUIUtility.hotControl) return position.Contains(Event.current.mousePosition); return false; default: return false; } }
public override void OnPreviewGUI(Rect r, GUIStyle background) { if (Event.current.type == EventType.Repaint) { background.Draw(r, false, false, false, false); } WebCamTexture webCamTexture = this.target as WebCamTexture; float num = Mathf.Min(Mathf.Min(r.width / (float)webCamTexture.width, r.height / (float)webCamTexture.height), 1f); Rect rect = new Rect(r.x, r.y, (float)webCamTexture.width * num, (float)webCamTexture.height * num); PreviewGUI.BeginScrollView(r, this.m_Pos, rect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb"); GUI.DrawTexture(rect, webCamTexture, ScaleMode.StretchToFill, false); this.m_Pos = PreviewGUI.EndScrollView(); if (webCamTexture.isPlaying) { GUIView.current.Repaint(); } if (Application.isPlaying) { if (webCamTexture.isPlaying) { EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10f, r.width, 20f), "Can't pause preview when in play mode"); } else { EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10f, r.width, 20f), "Can't start preview when in play mode"); } } }
public static int SelectionList(int selected, GUIContent[] list, GUIStyle elementStyle, DoubleClickCallback callback) { for (int i = 0; i < list.Length; ++i) { Rect elementRect = GUILayoutUtility.GetRect(list[i], elementStyle); bool hover = elementRect.Contains(Event.current.mousePosition); /* if (hover && Event.current.type == EventType.MouseDown) { selected = i; Event.current.Use(); } else if (hover && callback != null && Event.current.type == EventType.MouseUp && Event.current.clickCount == 2) { callback(i); Event.current.Use(); } else if (Event.current.type == EventType.repaint) { elementStyle.Draw(elementRect, list[i], hover, false, i == selected, false); } */ if (hover && Event.current.type == EventType.MouseDown && Event.current.clickCount == 1) { selected = i; Event.current.Use(); } else if (hover && callback != null && Event.current.type == EventType.MouseDown && Event.current.clickCount == 2) { callback(i); Event.current.Use(); } else if (Event.current.type == EventType.repaint) { elementStyle.Draw(elementRect, list[i], hover, false, i == selected, false); } } return selected; }
public static Vector2 Handle(GUIStyle style, int id, Vector2 position, bool allowKeyboardFocus) { int handleSize = (int)style.fixedWidth; Rect rect = new Rect(position.x - handleSize / 2, position.y - handleSize / 2, handleSize, handleSize); int controlID = id; switch (Event.current.GetTypeForControl(controlID)) { case EventType.MouseDown: { if (rect.Contains(Event.current.mousePosition)) { activePositionHandleId = id; if (allowKeyboardFocus) { GUIUtility.keyboardControl = controlID; } positionHandleOffset = Event.current.mousePosition - position; GUIUtility.hotControl = controlID; Event.current.Use(); } break; } case EventType.MouseDrag: { if (GUIUtility.hotControl == controlID) { position = Event.current.mousePosition - positionHandleOffset; Event.current.Use(); } break; } case EventType.MouseUp: { if (GUIUtility.hotControl == controlID) { activePositionHandleId = 0; position = Event.current.mousePosition - positionHandleOffset; GUIUtility.hotControl = 0; Event.current.Use(); } break; } case EventType.Repaint: { bool selected = (GUIUtility.keyboardControl == controlID || GUIUtility.hotControl == controlID); style.Draw(rect, selected, false, false, false); break; } } return position; }
//http://answers.unity3d.com/questions/315724/loading-gui-in-middle-of-mouse-and-make-it-work-ra.html public bool DisplaySelectActionButton(Rect aRect, GUIContent aContent, GUIStyle aStyle) { Event e = Event.current; bool isOver = aRect.Contains(e.mousePosition); if (e.type == EventType.Repaint) aStyle.Draw(aRect, aContent, isOver, true, true, false); else if (isOver && e.type == EventType.MouseUp) return true; return false; }
public static void Splitter(float thickness, GUIStyle splitterStyle) { Rect position = GUILayoutUtility.GetRect(GUIContent.none, splitterStyle, GUILayout.Height(thickness)); if (Event.current.type == EventType.Repaint) { Color restoreColor = GUI.color; GUI.color = splitterColor; splitterStyle.Draw(position, false, false, false, false); GUI.color = restoreColor; } }
private static void DrawCap(int controlID, Vector3 position, GUIStyle guiStyle) { if (Event.current.type != EventType.Repaint) return; Handles.BeginGUI(); position = (Vector3) HandleUtility.WorldToGUIPoint(position); float fixedWidth = guiStyle.fixedWidth; float fixedHeight = guiStyle.fixedHeight; Rect position1 = new Rect(position.x - fixedWidth / 2f, position.y - fixedHeight / 2f, fixedWidth, fixedHeight); guiStyle.Draw(position1, GUIContent.none, controlID); Handles.EndGUI(); }
public static void DrawRetractedHeader(Rect position, GUIContent label, GUIStyle backgroundStyle) { var rbg = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight); if (Event.current.type == EventType.Repaint && backgroundStyle != null) backgroundStyle.Draw(rbg, false, false, false, false); var rlbl = rbg; rlbl.xMin += 6f; rlbl.xMax -= 6f; rlbl.y += 1f; EditorGUI.LabelField(rlbl, label); }
internal static Vector2 PointSlider(Vector2 pos, MouseCursor cursor, GUIStyle dragDot, GUIStyle dragDotActive) { int controlId = GUIUtility.GetControlID("Slider1D".GetHashCode(), FocusType.Keyboard); Vector2 vector2 = (Vector2) Handles.matrix.MultiplyPoint((Vector3) pos); Rect rect = new Rect(vector2.x - dragDot.fixedWidth * 0.5f, vector2.y - dragDot.fixedHeight * 0.5f, dragDot.fixedWidth, dragDot.fixedHeight); if (Event.current.GetTypeForControl(controlId) == EventType.Repaint) { if (GUIUtility.hotControl == controlId) dragDotActive.Draw(rect, GUIContent.none, controlId); else dragDot.Draw(rect, GUIContent.none, controlId); } return SpriteEditorHandles.ScaleSlider(pos, cursor, rect); }
public static void Splitter(float thickness, GUIStyle splitterStyle) { Rect rect = GUILayoutUtility.GetRect(GUIContent.none, splitterStyle, new GUILayoutOption[] { GUILayout.Height(thickness) }); if (Event.current.type == (EventType)7) { Color color = GUI.color; GUI.color = fiEditorGUILayout.splitterColor; splitterStyle.Draw(rect, false, false, false, false); GUI.color = color; } }
internal static int DoMaskField(Rect position, int controlID, int mask, string[] flagNames, GUIStyle style, out int changedFlags, out bool changedToValue) { mask = MaskFieldGUI.MaskCallbackInfo.GetSelectedValueForControl(controlID, mask, out changedFlags, out changedToValue); List<int> intList = new List<int>(); List<string> stringList = new List<string>() { "Nothing", "Everything" }; for (int index = 0; index < flagNames.Length; ++index) { if ((mask & 1 << index) != 0) intList.Add(index + 2); } stringList.AddRange((IEnumerable<string>) flagNames); GUIContent content = EditorGUI.mixedValueContent; if (!EditorGUI.showMixedValue) { switch (intList.Count) { case 0: content = EditorGUIUtility.TempContent("Nothing"); intList.Add(0); break; case 1: content = new GUIContent(stringList[intList[0]]); break; default: if (intList.Count >= flagNames.Length) { content = EditorGUIUtility.TempContent("Everything"); intList.Add(1); mask = -1; break; } content = EditorGUIUtility.TempContent("Mixed ..."); break; } } Event current = Event.current; if (current.type == EventType.Repaint) style.Draw(position, content, controlID, false); else if (current.type == EventType.MouseDown && position.Contains(current.mousePosition) || current.MainActionKeyForControl(controlID)) { MaskFieldGUI.MaskCallbackInfo.m_Instance = new MaskFieldGUI.MaskCallbackInfo(controlID); current.Use(); EditorUtility.DisplayCustomMenu(position, stringList.ToArray(), !EditorGUI.showMixedValue ? intList.ToArray() : new int[0], new EditorUtility.SelectMenuItemFunction(MaskFieldGUI.MaskCallbackInfo.m_Instance.SetMaskValueDelegate), (object) null); } return mask; }
public static void BeginGroup(Rect position, GUIContent content, GUIStyle style) { GUIUtility.CheckOnGUI(); int controlID = GUIUtility.GetControlID(s_BeginGroupHash, FocusType.Passive); if ((content != GUIContent.none) || (style != GUIStyle.none)) { if (Event.current.type == EventType.Repaint) { style.Draw(position, content, controlID); } else if (position.Contains(Event.current.mousePosition)) { GUIUtility.mouseUsed = true; } } GUIClip.Push(position, Vector2.zero, Vector2.zero, false); }
public override void OnPreviewGUI(Rect r, GUIStyle background) { if (Event.current.type == EventType.Repaint) background.Draw(r, false, false, false, false); MovieTexture target = this.target as MovieTexture; float num = Mathf.Min(Mathf.Min(r.width / (float) target.width, r.height / (float) target.height), 1f); Rect rect = new Rect(r.x, r.y, (float) target.width * num, (float) target.height * num); PreviewGUI.BeginScrollView(r, this.m_Pos, rect, (GUIStyle) "PreHorizontalScrollbar", (GUIStyle) "PreHorizontalScrollbarThumb"); EditorGUI.DrawPreviewTexture(rect, (Texture) target, (Material) null, ScaleMode.StretchToFill); this.m_Pos = PreviewGUI.EndScrollView(); if (target.isPlaying) GUIView.current.Repaint(); if (!Application.isPlaying) return; if (target.isPlaying) EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10f, r.width, 20f), "Can't pause preview when in play mode"); else EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10f, r.width, 20f), "Can't start preview when in play mode"); }
public static bool DrawFlashingButton(Rect rc, GUIContent content, GUIStyle style) { int controlID = GUIUtility.GetControlID(FocusType.Native); // Get (or create) the state object var state = (FlashingButtonInfo)GUIUtility.GetStateObject( typeof(FlashingButtonInfo), controlID); switch (Event.current.GetTypeForControl(controlID)) { case EventType.Repaint: { GUI.color = state.IsFlashing(controlID) ? Color.red : Color.green; style.Draw(rc, content, controlID); break; } case EventType.MouseDown: { if (rc.Contains(Event.current.mousePosition) && Event.current.button == 0 && GUIUtility.hotControl == 0) { GUIUtility.hotControl = controlID; state.MouseDownNow(); } break; } case EventType.MouseUp: { if (GUIUtility.hotControl == controlID) GUIUtility.hotControl = 0; break; } } return GUIUtility.hotControl == controlID; }
public static bool EditorButton (Rect position, int controlID, GUIContent content, GUIStyle style) { switch (Event.current.GetTypeForControl(controlID)) { case EventType.MouseDown: if (position.Contains(Event.current.mousePosition)) { EditorGUIUtility.hotControl = controlID; Event.current.Use(); } return false; case EventType.MouseUp: if (EditorGUIUtility.hotControl == controlID) { EditorGUIUtility.hotControl = 0; EditorGUIUtility.keyboardControl = controlID; Event.current.Use(); return position.Contains(Event.current.mousePosition); } return false; #if !UNITY_4_0_0 && !UNITY_4_1 && !UNITY_4_2 case EventType.KeyDown: if (EditorGUIUtility.keyboardControl == controlID && Event.current.keyCode == KeyCode.Space && (int)Event.current.modifiers == 0) { Event.current.Use(); return true; } break; #endif case EventType.MouseDrag: if (EditorGUIUtility.hotControl == controlID) Event.current.Use(); break; case EventType.Repaint: style.Draw(position, content, controlID); break; } return false; }
public static GridPivot PivotPointSelector(GridPivot pivot) { // Find required styles gridPivotSelectBackground = gridPivotSelectBackground ?? AstarPathEditor.astarSkin.FindStyle("GridPivotSelectBackground"); gridPivotSelectButton = gridPivotSelectButton ?? AstarPathEditor.astarSkin.FindStyle("GridPivotSelectButton"); Rect r = GUILayoutUtility.GetRect(19, 19, gridPivotSelectBackground); // I have no idea why... but this is required for it to work well r.y -= 14; r.width = 19; r.height = 19; if (gridPivotSelectBackground == null) { return pivot; } if (Event.current.type == EventType.Repaint) { gridPivotSelectBackground.Draw(r, false, false, false, false); } if (GUI.Toggle(new Rect(r.x, r.y, 7, 7), pivot == GridPivot.TopLeft, "", gridPivotSelectButton)) pivot = GridPivot.TopLeft; if (GUI.Toggle(new Rect(r.x+12, r.y, 7, 7), pivot == GridPivot.TopRight, "", gridPivotSelectButton)) pivot = GridPivot.TopRight; if (GUI.Toggle(new Rect(r.x+12, r.y+12, 7, 7), pivot == GridPivot.BottomRight, "", gridPivotSelectButton)) pivot = GridPivot.BottomRight; if (GUI.Toggle(new Rect(r.x, r.y+12, 7, 7), pivot == GridPivot.BottomLeft, "", gridPivotSelectButton)) pivot = GridPivot.BottomLeft; if (GUI.Toggle(new Rect(r.x+6, r.y+6, 7, 7), pivot == GridPivot.Center, "", gridPivotSelectButton)) pivot = GridPivot.Center; return pivot; }
private static void DrawImageBasedCap(int controlID, Vector3 position, Quaternion rotation, float size, GUIStyle normal, GUIStyle active) { if (Camera.current && Vector3.Dot(position - Camera.current.transform.position, Camera.current.transform.forward) < 0f) { return; } Vector3 vector = HandleUtility.WorldToGUIPoint(position); Handles.BeginGUI(); float fixedWidth = normal.fixedWidth; float fixedHeight = normal.fixedHeight; Rect position2 = new Rect(vector.x - fixedWidth / 2f, vector.y - fixedHeight / 2f, fixedWidth, fixedHeight); if (GUIUtility.hotControl == controlID) { active.Draw(position2, GUIContent.none, controlID); } else { normal.Draw(position2, GUIContent.none, controlID); } Handles.EndGUI(); }
internal static Vector2 PivotSlider(Rect sprite, Vector2 pos, GUIStyle pivotDot, GUIStyle pivotDotActive) { int controlID = GUIUtility.GetControlID("Slider1D".GetHashCode(), FocusType.Keyboard); pos = new Vector2(sprite.xMin + (sprite.width * pos.x), sprite.yMin + (sprite.height * pos.y)); Vector2 vector = Handles.matrix.MultiplyPoint((Vector3) pos); Rect position = new Rect(vector.x - (pivotDot.fixedWidth * 0.5f), vector.y - (pivotDot.fixedHeight * 0.5f), pivotDotActive.fixedWidth, pivotDotActive.fixedHeight); Event current = Event.current; switch (current.GetTypeForControl(controlID)) { case EventType.MouseDown: if (((current.button == 0) && position.Contains(Event.current.mousePosition)) && !current.alt) { int num2 = controlID; GUIUtility.keyboardControl = num2; GUIUtility.hotControl = num2; s_CurrentMousePosition = current.mousePosition; s_DragStartScreenPosition = current.mousePosition; Vector2 vector2 = Handles.matrix.MultiplyPoint((Vector3) pos); s_DragScreenOffset = s_CurrentMousePosition - vector2; current.Use(); EditorGUIUtility.SetWantsMouseJumping(1); } break; case EventType.MouseUp: if ((GUIUtility.hotControl == controlID) && ((current.button == 0) || (current.button == 2))) { GUIUtility.hotControl = 0; current.Use(); EditorGUIUtility.SetWantsMouseJumping(0); } break; case EventType.MouseDrag: if (GUIUtility.hotControl == controlID) { s_CurrentMousePosition += current.delta; Vector2 vector3 = pos; Vector3 vector4 = Handles.s_InverseMatrix.MultiplyPoint((Vector3) (s_CurrentMousePosition - s_DragScreenOffset)); pos = new Vector2(vector4.x, vector4.y); Vector2 vector5 = vector3 - pos; if (!Mathf.Approximately(vector5.magnitude, 0f)) { GUI.changed = true; } current.Use(); } break; case EventType.KeyDown: if ((GUIUtility.hotControl == controlID) && (current.keyCode == KeyCode.Escape)) { pos = Handles.s_InverseMatrix.MultiplyPoint((Vector3) (s_DragStartScreenPosition - s_DragScreenOffset)); GUIUtility.hotControl = 0; GUI.changed = true; current.Use(); } break; case EventType.Repaint: EditorGUIUtility.AddCursorRect(position, MouseCursor.Arrow, controlID); if (GUIUtility.hotControl != controlID) { pivotDot.Draw(position, GUIContent.none, controlID); break; } pivotDotActive.Draw(position, GUIContent.none, controlID); break; } pos = new Vector2((pos.x - sprite.xMin) / sprite.width, (pos.y - sprite.yMin) / sprite.height); return pos; }
private float OnRepaint() { bool hover = GUIUtility.HitTest(position, CurrentEvent()); slider.Draw(position, GUIContent.none, id, false, hover); if (currentValue >= Mathf.Min(start, end) && currentValue <= Mathf.Max(start, end)) { if (thumbExtent != null) { thumbExtent.Draw(ThumbExtRect(), GUIContent.none, id, false, hover); } thumb.Draw(ThumbRect(), GUIContent.none, id, false, hover); } if (GUIUtility.hotControl != id || !hover || IsEmptySlider()) { return(currentValue); } var thumbRect = ThumbRect(); // If the slider is horizontal then use its entire height to hit test on the thumb if (this.horiz) { thumbRect.y = position.y; thumbRect.height = position.height; } // ... otherwise use the entire width else { thumbRect.x = position.x; thumbRect.width = position.width; } if (GUIUtility.HitTest(thumbRect, CurrentEvent())) { if (GUI.scrollTroughSide != 0) // if was scrolling with "trough" and the thumb reached mouse - sliding action over { GUIUtility.hotControl = 0; } return(currentValue); } GUI.InternalRepaintEditorWindow(); if (SystemClock.now < GUI.nextScrollStepTime) { return(currentValue); } if (CurrentScrollTroughSide() != GUI.scrollTroughSide) { return(currentValue); } GUI.nextScrollStepTime = SystemClock.now.AddMilliseconds(ScrollWaitDefinitions.regularWait); if (SupportsPageMovements()) { SliderState().isDragging = false; GUI.changed = true; return(PageMovementValue()); } return(ClampedCurrentValue()); }
static int Draw(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.GUIStyle), typeof(UnityEngine.Rect), typeof(UnityEngine.GUIContent), typeof(int))) { UnityEngine.GUIStyle obj = (UnityEngine.GUIStyle)ToLua.ToObject(L, 1); UnityEngine.Rect arg0 = (UnityEngine.Rect)ToLua.ToObject(L, 2); UnityEngine.GUIContent arg1 = (UnityEngine.GUIContent)ToLua.ToObject(L, 3); int arg2 = (int)LuaDLL.lua_tonumber(L, 4); obj.Draw(arg0, arg1, arg2); return(0); } else if (count == 5 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.GUIStyle), typeof(UnityEngine.Rect), typeof(UnityEngine.GUIContent), typeof(int), typeof(bool))) { UnityEngine.GUIStyle obj = (UnityEngine.GUIStyle)ToLua.ToObject(L, 1); UnityEngine.Rect arg0 = (UnityEngine.Rect)ToLua.ToObject(L, 2); UnityEngine.GUIContent arg1 = (UnityEngine.GUIContent)ToLua.ToObject(L, 3); int arg2 = (int)LuaDLL.lua_tonumber(L, 4); bool arg3 = LuaDLL.lua_toboolean(L, 5); obj.Draw(arg0, arg1, arg2, arg3); return(0); } else if (count == 6 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.GUIStyle), typeof(UnityEngine.Rect), typeof(bool), typeof(bool), typeof(bool), typeof(bool))) { UnityEngine.GUIStyle obj = (UnityEngine.GUIStyle)ToLua.ToObject(L, 1); UnityEngine.Rect arg0 = (UnityEngine.Rect)ToLua.ToObject(L, 2); bool arg1 = LuaDLL.lua_toboolean(L, 3); bool arg2 = LuaDLL.lua_toboolean(L, 4); bool arg3 = LuaDLL.lua_toboolean(L, 5); bool arg4 = LuaDLL.lua_toboolean(L, 6); obj.Draw(arg0, arg1, arg2, arg3, arg4); return(0); } else if (count == 7 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.GUIStyle), typeof(UnityEngine.Rect), typeof(UnityEngine.GUIContent), typeof(bool), typeof(bool), typeof(bool), typeof(bool))) { UnityEngine.GUIStyle obj = (UnityEngine.GUIStyle)ToLua.ToObject(L, 1); UnityEngine.Rect arg0 = (UnityEngine.Rect)ToLua.ToObject(L, 2); UnityEngine.GUIContent arg1 = (UnityEngine.GUIContent)ToLua.ToObject(L, 3); bool arg2 = LuaDLL.lua_toboolean(L, 4); bool arg3 = LuaDLL.lua_toboolean(L, 5); bool arg4 = LuaDLL.lua_toboolean(L, 6); bool arg5 = LuaDLL.lua_toboolean(L, 7); obj.Draw(arg0, arg1, arg2, arg3, arg4, arg5); return(0); } else if (count == 7 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.GUIStyle), typeof(UnityEngine.Rect), typeof(string), typeof(bool), typeof(bool), typeof(bool), typeof(bool))) { UnityEngine.GUIStyle obj = (UnityEngine.GUIStyle)ToLua.ToObject(L, 1); UnityEngine.Rect arg0 = (UnityEngine.Rect)ToLua.ToObject(L, 2); string arg1 = ToLua.ToString(L, 3); bool arg2 = LuaDLL.lua_toboolean(L, 4); bool arg3 = LuaDLL.lua_toboolean(L, 5); bool arg4 = LuaDLL.lua_toboolean(L, 6); bool arg5 = LuaDLL.lua_toboolean(L, 7); obj.Draw(arg0, arg1, arg2, arg3, arg4, arg5); return(0); } else if (count == 7 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.GUIStyle), typeof(UnityEngine.Rect), typeof(UnityEngine.Texture), typeof(bool), typeof(bool), typeof(bool), typeof(bool))) { UnityEngine.GUIStyle obj = (UnityEngine.GUIStyle)ToLua.ToObject(L, 1); UnityEngine.Rect arg0 = (UnityEngine.Rect)ToLua.ToObject(L, 2); UnityEngine.Texture arg1 = (UnityEngine.Texture)ToLua.ToObject(L, 3); bool arg2 = LuaDLL.lua_toboolean(L, 4); bool arg3 = LuaDLL.lua_toboolean(L, 5); bool arg4 = LuaDLL.lua_toboolean(L, 6); bool arg5 = LuaDLL.lua_toboolean(L, 7); obj.Draw(arg0, arg1, arg2, arg3, arg4, arg5); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.GUIStyle.Draw")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
internal static Vector2 PointSlider(Vector2 pos, MouseCursor cursor, GUIStyle dragDot, GUIStyle dragDotActive) { int controlID = GUIUtility.GetControlID("Slider1D".GetHashCode(), FocusType.Keyboard); Vector2 vector = Handles.matrix.MultiplyPoint((Vector3) pos); Rect position = new Rect(vector.x - (dragDot.fixedWidth * 0.5f), vector.y - (dragDot.fixedHeight * 0.5f), dragDot.fixedWidth, dragDot.fixedHeight); if (Event.current.GetTypeForControl(controlID) == EventType.Repaint) { if (GUIUtility.hotControl == controlID) { dragDotActive.Draw(position, GUIContent.none, controlID); } else { dragDot.Draw(position, GUIContent.none, controlID); } } return ScaleSlider(pos, cursor, position); }
public static void Splitter(Color rgb, float thickness = 1, int margin = 0) { GUIStyle splitter = new GUIStyle(); splitter.normal.background = EditorGUIUtility.whiteTexture; splitter.stretchWidth = true; splitter.margin = new RectOffset(margin, margin, 7, 7); Rect position = GUILayoutUtility.GetRect(GUIContent.none, splitter, GUILayout.Height(thickness)); if(Event.current.type == EventType.Repaint) { Color restoreColor = GUI.color; GUI.color = rgb; splitter.Draw(position, false, false, false, false); GUI.color = restoreColor; } }
public override void OnPreviewGUI(Rect r, GUIStyle background) { if (Event.current.type == EventType.Repaint) { background.Draw(r, false, false, false, false); } Texture target = base.target as Texture; RenderTexture texture2 = target as RenderTexture; if (texture2 != null) { if (!SystemInfo.SupportsRenderTextureFormat(texture2.format)) { return; } texture2.Create(); } if (this.IsCubemap()) { this.m_CubemapPreview.OnPreviewGUI(target, r, background); } else { int num = Mathf.Max(target.width, 1); int num2 = Mathf.Max(target.height, 1); float mipLevelForRendering = this.GetMipLevelForRendering(); float num4 = Mathf.Min(Mathf.Min((float) (r.width / ((float) num)), (float) (r.height / ((float) num2))), 1f); Rect viewRect = new Rect(r.x, r.y, num * num4, num2 * num4); PreviewGUI.BeginScrollView(r, this.m_Pos, viewRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb"); float mipMapBias = target.mipMapBias; TextureUtil.SetMipMapBiasNoDirty(target, mipLevelForRendering - this.Log2(((float) num) / viewRect.width)); FilterMode filterMode = target.filterMode; TextureUtil.SetFilterModeNoDirty(target, FilterMode.Point); if (this.m_ShowAlpha) { EditorGUI.DrawTextureAlpha(viewRect, target); } else { Texture2D textured = target as Texture2D; if ((textured != null) && textured.alphaIsTransparency) { EditorGUI.DrawTextureTransparent(viewRect, target); } else { EditorGUI.DrawPreviewTexture(viewRect, target); } } if ((viewRect.width > 32f) && (viewRect.height > 32f)) { TextureImporter atPath = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(target)) as TextureImporter; SpriteMetaData[] dataArray = (atPath == null) ? null : atPath.spritesheet; if ((dataArray != null) && (atPath.spriteImportMode == SpriteImportMode.Multiple)) { Rect outScreenRect = new Rect(); Rect outSourceRect = new Rect(); GUI.CalculateScaledTextureRects(viewRect, ScaleMode.StretchToFill, ((float) target.width) / ((float) target.height), ref outScreenRect, ref outSourceRect); int width = target.width; int height = target.height; atPath.GetWidthAndHeight(ref width, ref height); float num8 = ((float) target.width) / ((float) width); HandleUtility.ApplyWireMaterial(); GL.PushMatrix(); GL.MultMatrix(Handles.matrix); GL.Begin(1); GL.Color(new Color(1f, 1f, 1f, 0.5f)); foreach (SpriteMetaData data in dataArray) { Rect rect = data.rect; Rect rect5 = new Rect { xMin = outScreenRect.xMin + (outScreenRect.width * ((rect.xMin / ((float) target.width)) * num8)), xMax = outScreenRect.xMin + (outScreenRect.width * ((rect.xMax / ((float) target.width)) * num8)), yMin = outScreenRect.yMin + (outScreenRect.height * (1f - ((rect.yMin / ((float) target.height)) * num8))), yMax = outScreenRect.yMin + (outScreenRect.height * (1f - ((rect.yMax / ((float) target.height)) * num8))) }; this.DrawRect(rect5); } GL.End(); GL.PopMatrix(); } } TextureUtil.SetMipMapBiasNoDirty(target, mipMapBias); TextureUtil.SetFilterModeNoDirty(target, filterMode); this.m_Pos = PreviewGUI.EndScrollView(); if (mipLevelForRendering != 0f) { EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 20f), "Mip " + mipLevelForRendering); } } }
public static HighLevelEvent MultiSelection(Rect rect, Rect[] positions, GUIContent content, Rect[] hitPositions, ref bool[] selections, bool[] readOnly, out int clickedIndex, out Vector2 offset, out float startSelect, out float endSelect, GUIStyle style) { int controlID = GUIUtility.GetControlID(0x27b1f9d, FocusType.Keyboard); Event current = Event.current; offset = Vector2.zero; clickedIndex = -1; startSelect = endSelect = 0f; if (current.type != EventType.Used) { int indexUnderMouse; bool flag = false; if (GUIUtility.keyboardControl == controlID) { flag = true; } else { selections = new bool[selections.Length]; } switch (current.GetTypeForControl(controlID)) { case EventType.MouseDown: if (current.button != 0) { break; } GUIUtility.hotControl = controlID; GUIUtility.keyboardControl = controlID; s_StartSelectPos = current.mousePosition; indexUnderMouse = GetIndexUnderMouse(hitPositions, readOnly); if ((Event.current.clickCount != 2) || (indexUnderMouse < 0)) { if (indexUnderMouse >= 0) { if ((!current.shift && !EditorGUI.actionKey) && !selections[indexUnderMouse]) { for (int j = 0; j < hitPositions.Length; j++) { selections[j] = false; } } if (current.shift || EditorGUI.actionKey) { selections[indexUnderMouse] = !selections[indexUnderMouse]; } else { selections[indexUnderMouse] = true; } s_MouseDownPos = current.mousePosition; s_MultiSelectDragSelection = DragSelectionState.None; current.Use(); clickedIndex = indexUnderMouse; return HighLevelEvent.SelectionChanged; } bool flag2 = false; if (!current.shift && !EditorGUI.actionKey) { for (int k = 0; k < hitPositions.Length; k++) { selections[k] = false; } flag2 = true; } else { flag2 = false; } s_SelectionBackup = new List<bool>(selections); s_LastFrameSelections = new List<bool>(selections); s_MultiSelectDragSelection = DragSelectionState.DragSelecting; current.Use(); return (!flag2 ? HighLevelEvent.None : HighLevelEvent.SelectionChanged); } for (int i = 0; i < selections.Length; i++) { selections[i] = false; } selections[indexUnderMouse] = true; current.Use(); clickedIndex = indexUnderMouse; return HighLevelEvent.DoubleClick; case EventType.MouseUp: if (GUIUtility.hotControl != controlID) { break; } GUIUtility.hotControl = 0; if (s_StartSelectPos != current.mousePosition) { current.Use(); } if (s_MultiSelectDragSelection == DragSelectionState.None) { clickedIndex = GetIndexUnderMouse(hitPositions, readOnly); if (current.clickCount == 1) { return HighLevelEvent.Click; } break; } s_MultiSelectDragSelection = DragSelectionState.None; s_SelectionBackup = null; s_LastFrameSelections = null; return HighLevelEvent.EndDrag; case EventType.MouseDrag: { if (GUIUtility.hotControl != controlID) { break; } if (s_MultiSelectDragSelection != DragSelectionState.DragSelecting) { offset = current.mousePosition - s_MouseDownPos; current.Use(); if (s_MultiSelectDragSelection == DragSelectionState.None) { s_MultiSelectDragSelection = DragSelectionState.Dragging; return HighLevelEvent.BeginDrag; } return HighLevelEvent.Drag; } float num9 = Mathf.Min(s_StartSelectPos.x, current.mousePosition.x); float num10 = Mathf.Max(s_StartSelectPos.x, current.mousePosition.x); s_SelectionBackup.CopyTo(selections); for (int m = 0; m < hitPositions.Length; m++) { if (!selections[m]) { float num12 = hitPositions[m].x + (hitPositions[m].width * 0.5f); if ((num12 >= num9) && (num12 <= num10)) { selections[m] = true; } } } current.Use(); startSelect = num9; endSelect = num10; bool flag3 = false; for (int n = 0; n < selections.Length; n++) { if (selections[n] != s_LastFrameSelections[n]) { flag3 = true; s_LastFrameSelections[n] = selections[n]; } } return (!flag3 ? HighLevelEvent.None : HighLevelEvent.SelectionChanged); } case EventType.KeyDown: if (!flag || ((current.keyCode != KeyCode.Backspace) && (current.keyCode != KeyCode.Delete))) { break; } current.Use(); return HighLevelEvent.Delete; case EventType.Repaint: { if ((GUIUtility.hotControl == controlID) && (s_MultiSelectDragSelection == DragSelectionState.DragSelecting)) { float num3 = Mathf.Min(s_StartSelectPos.x, current.mousePosition.x); float num4 = Mathf.Max(s_StartSelectPos.x, current.mousePosition.x); Rect position = new Rect(0f, 0f, rect.width, rect.height) { x = num3, width = num4 - num3 }; if (position.width != 0f) { GUI.Box(position, string.Empty, ms_Styles.selectionRect); } } Color color = GUI.color; for (int num5 = 0; num5 < positions.Length; num5++) { if ((readOnly != null) && readOnly[num5]) { GUI.color = color * new Color(0.9f, 0.9f, 0.9f, 0.5f); } else if (selections[num5]) { GUI.color = color * new Color(0.3f, 0.55f, 0.95f, 1f); } else { GUI.color = color * new Color(0.9f, 0.9f, 0.9f, 1f); } style.Draw(positions[num5], content, controlID, selections[num5]); } GUI.color = color; break; } case EventType.ValidateCommand: case EventType.ExecuteCommand: { int num15; if (!flag) { break; } bool flag4 = current.type == EventType.ExecuteCommand; string commandName = current.commandName; if (commandName == null) { break; } if (<>f__switch$mapC == null) { Dictionary<string, int> dictionary = new Dictionary<string, int>(1); dictionary.Add("Delete", 0); <>f__switch$mapC = dictionary; } if (!<>f__switch$mapC.TryGetValue(commandName, out num15) || (num15 != 0)) { break; } current.Use(); if (!flag4) { break; } return HighLevelEvent.Delete; } case EventType.ContextClick: indexUnderMouse = GetIndexUnderMouse(hitPositions, readOnly); if (indexUnderMouse < 0) { break; } clickedIndex = indexUnderMouse; GUIUtility.keyboardControl = controlID; current.Use(); return HighLevelEvent.ContextClick; } } return HighLevelEvent.None; }
internal static void DoMinMaxSlider(Rect position, int id, ref float value, ref float size, float visualStart, float visualEnd, float startLimit, float endLimit, GUIStyle slider, GUIStyle thumb, bool horiz) { float num9; float num10; Rect rect; Rect rect2; Rect rect3; float num13; float num14; Event current = Event.current; bool flag = size == 0f; float min = Mathf.Min(visualStart, visualEnd); float max = Mathf.Max(visualStart, visualEnd); float dragStartLimit = Mathf.Min(startLimit, endLimit); float dragEndLimit = Mathf.Max(startLimit, endLimit); MinMaxSliderState state = s_MinMaxSliderState; if ((GUIUtility.hotControl == id) && (state != null)) { min = state.dragStartLimit; dragStartLimit = state.dragStartLimit; max = state.dragEndLimit; dragEndLimit = state.dragEndLimit; } float num5 = 0f; float num6 = Mathf.Clamp(value, min, max); float num7 = Mathf.Clamp(value + size, min, max) - num6; float num8 = (visualStart <= visualEnd) ? ((float) 1) : ((float) (-1)); if ((slider == null) || (thumb == null)) { return; } if (horiz) { float num11 = (thumb.fixedWidth == 0f) ? ((float) thumb.padding.horizontal) : thumb.fixedWidth; num9 = ((position.width - slider.padding.horizontal) - num11) / (max - min); rect = new Rect((((num6 - min) * num9) + position.x) + slider.padding.left, position.y + slider.padding.top, (num7 * num9) + num11, position.height - slider.padding.vertical); rect2 = new Rect(rect.x, rect.y, (float) thumb.padding.left, rect.height); rect3 = new Rect(rect.xMax - thumb.padding.right, rect.y, (float) thumb.padding.right, rect.height); num10 = current.mousePosition.x - position.x; } else { float num12 = (thumb.fixedHeight == 0f) ? ((float) thumb.padding.vertical) : thumb.fixedHeight; num9 = ((position.height - slider.padding.vertical) - num12) / (max - min); rect = new Rect(position.x + slider.padding.left, (((num6 - min) * num9) + position.y) + slider.padding.top, position.width - slider.padding.horizontal, (num7 * num9) + num12); rect2 = new Rect(rect.x, rect.y, rect.width, (float) thumb.padding.top); rect3 = new Rect(rect.x, rect.yMax - thumb.padding.bottom, rect.width, (float) thumb.padding.bottom); num10 = current.mousePosition.y - position.y; } switch (current.GetTypeForControl(id)) { case EventType.MouseDown: if (position.Contains(current.mousePosition) && ((min - max) != 0f)) { if (state == null) { state = s_MinMaxSliderState = new MinMaxSliderState(); } state.dragStartLimit = startLimit; state.dragEndLimit = endLimit; if (rect.Contains(current.mousePosition)) { state.dragStartPos = num10; state.dragStartValue = value; state.dragStartSize = size; state.dragStartValuesPerPixel = num9; if (rect2.Contains(current.mousePosition)) { state.whereWeDrag = 1; } else if (rect3.Contains(current.mousePosition)) { state.whereWeDrag = 2; } else { state.whereWeDrag = 0; } GUIUtility.hotControl = id; current.Use(); return; } if (slider != GUIStyle.none) { if ((size != 0f) && flag) { if (horiz) { if (num10 > (rect.xMax - position.x)) { value += (size * num8) * 0.9f; } else { value -= (size * num8) * 0.9f; } } else if (num10 > (rect.yMax - position.y)) { value += (size * num8) * 0.9f; } else { value -= (size * num8) * 0.9f; } state.whereWeDrag = 0; GUI.changed = true; s_NextScrollStepTime = DateTime.Now.AddMilliseconds((double) kFirstScrollWait); num13 = !horiz ? current.mousePosition.y : current.mousePosition.x; num14 = !horiz ? rect.y : rect.x; state.whereWeDrag = (num13 <= num14) ? 3 : 4; } else { if (horiz) { value = (((num10 - (rect.width * 0.5f)) / num9) + min) - (size * 0.5f); } else { value = (((num10 - (rect.height * 0.5f)) / num9) + min) - (size * 0.5f); } state.dragStartPos = num10; state.dragStartValue = value; state.dragStartSize = size; state.dragStartValuesPerPixel = num9; state.whereWeDrag = 0; GUI.changed = true; } GUIUtility.hotControl = id; value = Mathf.Clamp(value, dragStartLimit, dragEndLimit - size); current.Use(); } return; } return; case EventType.MouseUp: if (GUIUtility.hotControl == id) { current.Use(); GUIUtility.hotControl = 0; } return; case EventType.MouseMove: case EventType.KeyDown: case EventType.KeyUp: case EventType.ScrollWheel: return; case EventType.MouseDrag: if (GUIUtility.hotControl == id) { float num15 = (num10 - state.dragStartPos) / state.dragStartValuesPerPixel; switch (state.whereWeDrag) { case 0: value = Mathf.Clamp(state.dragStartValue + num15, dragStartLimit, dragEndLimit - size); goto Label_069F; case 1: value = state.dragStartValue + num15; size = state.dragStartSize - num15; if (value < dragStartLimit) { size -= dragStartLimit - value; value = dragStartLimit; } if (size < num5) { value -= num5 - size; size = num5; } goto Label_069F; case 2: size = state.dragStartSize + num15; if ((value + size) > dragEndLimit) { size = dragEndLimit - value; } if (size < num5) { size = num5; } goto Label_069F; } break; } return; case EventType.Repaint: slider.Draw(position, GUIContent.none, id); thumb.Draw(rect, GUIContent.none, id); if (((GUIUtility.hotControl == id) && position.Contains(current.mousePosition)) && ((min - max) != 0f)) { if (rect.Contains(current.mousePosition)) { if ((state != null) && ((state.whereWeDrag == 3) || (state.whereWeDrag == 4))) { GUIUtility.hotControl = 0; } return; } if (DateTime.Now >= s_NextScrollStepTime) { num13 = !horiz ? current.mousePosition.y : current.mousePosition.x; num14 = !horiz ? rect.y : rect.x; int num16 = (num13 <= num14) ? 3 : 4; if (num16 != state.whereWeDrag) { return; } if ((size != 0f) && flag) { if (horiz) { if (num10 > (rect.xMax - position.x)) { value += (size * num8) * 0.9f; } else { value -= (size * num8) * 0.9f; } } else if (num10 > (rect.yMax - position.y)) { value += (size * num8) * 0.9f; } else { value -= (size * num8) * 0.9f; } state.whereWeDrag = -1; GUI.changed = true; } value = Mathf.Clamp(value, dragStartLimit, dragEndLimit - size); s_NextScrollStepTime = DateTime.Now.AddMilliseconds((double) kScrollWait); } return; } return; default: return; } Label_069F: GUI.changed = true; current.Use(); }
public static bool DragSelection(Rect[] positions, ref bool[] selections, GUIStyle style) { bool flag; int num5; int controlID = GUIUtility.GetControlID(0x20f3dc7, FocusType.Keyboard); Event current = Event.current; int index = -1; for (int i = positions.Length - 1; i >= 0; i--) { if (positions[i].Contains(current.mousePosition)) { index = i; break; } } switch (current.GetTypeForControl(controlID)) { case EventType.MouseDown: { if ((current.button != 0) || (index < 0)) { goto Label_02ED; } GUIUtility.keyboardControl = 0; flag = false; if (!selections[index]) { goto Label_012C; } num5 = 0; bool[] flagArray = selections; for (int j = 0; j < flagArray.Length; j++) { if (flagArray[j]) { num5++; if (num5 > 1) { break; } } } break; } case EventType.MouseUp: if (GUIUtility.hotControl == controlID) { GUIUtility.hotControl = 0; } goto Label_02ED; case EventType.MouseDrag: { if ((GUIUtility.hotControl != controlID) || (current.button != 0)) { goto Label_02ED; } if (index < 0) { Rect rect = new Rect(positions[0].x, positions[0].y - 200f, positions[0].width, 200f); if (rect.Contains(current.mousePosition)) { index = 0; } rect.y = positions[positions.Length - 1].yMax; if (rect.Contains(current.mousePosition)) { index = selections.Length - 1; } } if (index < 0) { return false; } int num8 = Mathf.Min(initIndex, index); int num9 = Mathf.Max(initIndex, index); for (int k = 0; k < selections.Length; k++) { if ((k >= num8) && (k <= num9)) { selections[k] = adding; } else { selections[k] = initSelections[k]; } } current.Use(); return true; } case EventType.Repaint: for (int m = 0; m < positions.Length; m++) { style.Draw(positions[m], GUIContent.none, controlID, selections[m]); } goto Label_02ED; default: goto Label_02ED; } if (num5 == 1) { flag = true; } Label_012C: if (!current.shift && !EditorGUI.actionKey) { for (int n = 0; n < positions.Length; n++) { selections[n] = false; } } initIndex = index; initSelections = (bool[]) selections.Clone(); adding = true; if ((current.shift || EditorGUI.actionKey) && selections[index]) { adding = false; } selections[index] = !flag ? adding : false; GUIUtility.hotControl = controlID; current.Use(); return true; Label_02ED: return false; }
private Vector2 Slider2D(Rect rect, Vector2 value, Vector2 maxvalue, Vector2 minvalue, GUIStyle backStyle, GUIStyle thumbStyle) { if (backStyle == null || thumbStyle == null) return value; int controlId = GUIUtility.GetControlID(ColorPicker.s_Slider2Dhash, FocusType.Native); if ((double) maxvalue.x < (double) minvalue.x) ColorPicker.swap(ref maxvalue.x, ref minvalue.x); if ((double) maxvalue.y < (double) minvalue.y) ColorPicker.swap(ref maxvalue.y, ref minvalue.y); float height = (double) thumbStyle.fixedHeight != 0.0 ? thumbStyle.fixedHeight : (float) thumbStyle.padding.vertical; float width = (double) thumbStyle.fixedWidth != 0.0 ? thumbStyle.fixedWidth : (float) thumbStyle.padding.horizontal; Vector2 vector2 = new Vector2((float) (((double) rect.width - (double) (backStyle.padding.right + backStyle.padding.left) - (double) width * 2.0) / ((double) maxvalue.x - (double) minvalue.x)), (float) (((double) rect.height - (double) (backStyle.padding.top + backStyle.padding.bottom) - (double) height * 2.0) / ((double) maxvalue.y - (double) minvalue.y))); Rect position = new Rect((float) ((double) rect.x + (double) value.x * (double) vector2.x + (double) width / 2.0 + (double) backStyle.padding.left - (double) minvalue.x * (double) vector2.x), (float) ((double) rect.y + (double) value.y * (double) vector2.y + (double) height / 2.0 + (double) backStyle.padding.top - (double) minvalue.y * (double) vector2.y), width, height); Event current = Event.current; switch (current.GetTypeForControl(controlId)) { case EventType.MouseDown: if (rect.Contains(current.mousePosition)) { GUIUtility.hotControl = controlId; GUIUtility.keyboardControl = 0; value.x = (current.mousePosition.x - rect.x - width - (float) backStyle.padding.left) / vector2.x + minvalue.x; value.y = (current.mousePosition.y - rect.y - height - (float) backStyle.padding.top) / vector2.y + minvalue.y; GUI.changed = true; Event.current.Use(); break; } break; case EventType.MouseUp: if (GUIUtility.hotControl == controlId) { GUIUtility.hotControl = 0; current.Use(); break; } break; case EventType.MouseDrag: if (GUIUtility.hotControl == controlId) { value.x = (current.mousePosition.x - rect.x - width - (float) backStyle.padding.left) / vector2.x + minvalue.x; value.y = (current.mousePosition.y - rect.y - height - (float) backStyle.padding.top) / vector2.y + minvalue.y; value.x = Mathf.Clamp(value.x, minvalue.x, maxvalue.x); value.y = Mathf.Clamp(value.y, minvalue.y, maxvalue.y); GUI.changed = true; Event.current.Use(); break; } break; case EventType.Repaint: backStyle.Draw(rect, GUIContent.none, controlId); Color color = GUI.color; bool flag = (double) ColorPicker.color.grayscale > 0.5; if (flag) GUI.color = Color.black; thumbStyle.Draw(position, GUIContent.none, controlId); if (flag) { GUI.color = color; break; } break; } return value; }
static public int Draw(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 4) { UnityEngine.GUIStyle self = (UnityEngine.GUIStyle)checkSelf(l); UnityEngine.Rect a1; checkValueType(l, 2, out a1); UnityEngine.GUIContent a2; checkType(l, 3, out a2); System.Int32 a3; checkType(l, 4, out a3); self.Draw(a1, a2, a3); pushValue(l, true); return(1); } else if (argc == 5) { UnityEngine.GUIStyle self = (UnityEngine.GUIStyle)checkSelf(l); UnityEngine.Rect a1; checkValueType(l, 2, out a1); UnityEngine.GUIContent a2; checkType(l, 3, out a2); System.Int32 a3; checkType(l, 4, out a3); System.Boolean a4; checkType(l, 5, out a4); self.Draw(a1, a2, a3, a4); pushValue(l, true); return(1); } else if (argc == 6) { UnityEngine.GUIStyle self = (UnityEngine.GUIStyle)checkSelf(l); UnityEngine.Rect a1; checkValueType(l, 2, out a1); System.Boolean a2; checkType(l, 3, out a2); System.Boolean a3; checkType(l, 4, out a3); System.Boolean a4; checkType(l, 5, out a4); System.Boolean a5; checkType(l, 6, out a5); self.Draw(a1, a2, a3, a4, a5); pushValue(l, true); return(1); } else if (matchType(l, argc, 2, typeof(UnityEngine.Rect), typeof(UnityEngine.GUIContent), typeof(bool), typeof(bool), typeof(bool), typeof(bool))) { UnityEngine.GUIStyle self = (UnityEngine.GUIStyle)checkSelf(l); UnityEngine.Rect a1; checkValueType(l, 2, out a1); UnityEngine.GUIContent a2; checkType(l, 3, out a2); System.Boolean a3; checkType(l, 4, out a3); System.Boolean a4; checkType(l, 5, out a4); System.Boolean a5; checkType(l, 6, out a5); System.Boolean a6; checkType(l, 7, out a6); self.Draw(a1, a2, a3, a4, a5, a6); pushValue(l, true); return(1); } else if (matchType(l, argc, 2, typeof(UnityEngine.Rect), typeof(string), typeof(bool), typeof(bool), typeof(bool), typeof(bool))) { UnityEngine.GUIStyle self = (UnityEngine.GUIStyle)checkSelf(l); UnityEngine.Rect a1; checkValueType(l, 2, out a1); System.String a2; checkType(l, 3, out a2); System.Boolean a3; checkType(l, 4, out a3); System.Boolean a4; checkType(l, 5, out a4); System.Boolean a5; checkType(l, 6, out a5); System.Boolean a6; checkType(l, 7, out a6); self.Draw(a1, a2, a3, a4, a5, a6); pushValue(l, true); return(1); } else if (matchType(l, argc, 2, typeof(UnityEngine.Rect), typeof(UnityEngine.Texture), typeof(bool), typeof(bool), typeof(bool), typeof(bool))) { UnityEngine.GUIStyle self = (UnityEngine.GUIStyle)checkSelf(l); UnityEngine.Rect a1; checkValueType(l, 2, out a1); UnityEngine.Texture a2; checkType(l, 3, out a2); System.Boolean a3; checkType(l, 4, out a3); System.Boolean a4; checkType(l, 5, out a4); System.Boolean a5; checkType(l, 6, out a5); System.Boolean a6; checkType(l, 7, out a6); self.Draw(a1, a2, a3, a4, a5, a6); pushValue(l, true); return(1); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
public TimeRulerDragMode BrowseRuler(Rect position, int id, ref float time, float frameRate, bool pickAnywhere, GUIStyle thumbStyle) { Event current = Event.current; Rect rect = position; if (time != -1f) { rect.x = Mathf.Round(base.TimeToPixel(time, position)) - thumbStyle.overflow.left; rect.width = thumbStyle.fixedWidth + thumbStyle.overflow.horizontal; } switch (current.GetTypeForControl(id)) { case EventType.MouseDown: if (!rect.Contains(current.mousePosition)) { if (pickAnywhere && position.Contains(current.mousePosition)) { GUIUtility.hotControl = id; float num = SnapTimeToWholeFPS(base.PixelToTime(current.mousePosition.x, position), frameRate); s_OriginalTime = time; if (num != time) { GUI.changed = true; } time = num; s_PickOffset = 0f; current.Use(); return TimeRulerDragMode.Start; } break; } GUIUtility.hotControl = id; s_PickOffset = current.mousePosition.x - base.TimeToPixel(time, position); current.Use(); return TimeRulerDragMode.Start; case EventType.MouseUp: if (GUIUtility.hotControl != id) { break; } GUIUtility.hotControl = 0; current.Use(); return TimeRulerDragMode.End; case EventType.MouseDrag: { if (GUIUtility.hotControl != id) { break; } float num2 = SnapTimeToWholeFPS(base.PixelToTime(current.mousePosition.x - s_PickOffset, position), frameRate); if (num2 != time) { GUI.changed = true; } time = num2; current.Use(); return TimeRulerDragMode.Dragging; } case EventType.KeyDown: if ((GUIUtility.hotControl != id) || (current.keyCode != KeyCode.Escape)) { break; } if (time != s_OriginalTime) { GUI.changed = true; } time = s_OriginalTime; GUIUtility.hotControl = 0; current.Use(); return TimeRulerDragMode.Cancel; case EventType.Repaint: if (time != -1f) { bool flag = position.Contains(current.mousePosition); rect.x += thumbStyle.overflow.left; thumbStyle.Draw(rect, id == GUIUtility.hotControl, flag || (id == GUIUtility.hotControl), false, false); } break; } return TimeRulerDragMode.None; }
public static void DrawHandle( int id, Vector3 point, GUIStyle style ) { if( Event.current == null || Event.current.type != EventType.repaint ) return; float fixedWidth = style.fixedWidth; float fixedHeight = style.fixedHeight; point = HandleUtility.WorldToGUIPoint( point ); var rect = new Rect( point.x - fixedWidth * 0.5f, point.y - fixedHeight * 0.5f, fixedWidth, fixedHeight ); style.Draw( rect, GUIContent.none, id, true ); }