public void AddChild(EditorGUIWidget widget) { if (childList.Contains(widget) == false) { childList.Add(widget); } }
public int GetIndexByWidget(EditorGUIWidget w) { for (int i = 0; i < AllWidget.Count; i++) { if (AllWidget[i] == w) return i; } return -1; }
public int GetIndexByWidget(EditorGUIWidget w) { for (int i = 0; i < AllWidget.Count; i++) { if (AllWidget[i] == w) { return(i); } } return(-1); }
public void Notify(EditorGUIWidget widget, EventGUIType guiType, object data) { if (widget == null) { Debug.Log(" Widget == null guitype " + guiType.ToString()); } if (widget.IsAutoDepth) { widget.SetAsFirstSibling(); } switch (guiType) { case EventGUIType.Hover: widget.OnHover(); for (int i = 0; i < mListens.Count; i++) { mListens[i].OnHover(widget); } Debug.Log("Hover"); break; case EventGUIType.Press: widget.OnPress((bool)data); for (int i = 0; i < mListens.Count; i++) { mListens[i].OnPress(widget, (bool)data); } Debug.Log("Press " + data.ToString()); break; case EventGUIType.Click: widget.OnClick(); for (int i = 0; i < mListens.Count; i++) { mListens[i].OnClick(widget); } Debug.Log("Click "); break; case EventGUIType.Drag: widget.OnDrag(nowEvent.delta); for (int i = 0; i < mListens.Count; i++) { mListens[i].OnDrag(widget, nowEvent.delta); } Debug.Log("Drag "); break; } }
protected float GetWholeWidth() { float result = 0; EditorGUIWidget temp = parent; while (temp != null) { result += 5f; temp = temp.parent; } return(result); }
private bool TryGetMouseStayWidget(Vector2 point, out EditorGUIWidget widget) { widget = null; for (int i = mAllWidgets.Count - 1; i >= 0; i--) { if (mAllWidgets[i].IsTrigger == false) { continue; } if (mAllWidgets[i].AreaRect.Contains(point)) { widget = mAllWidgets[i]; return(true); } } return(false); }
protected void SetParent(EditorGUIWidget widget) { if (parent == widget || this == widget) { return; } if (parent != null) { parent.RemoveChild(this); } if (widget != null) { widget.AddChild(this); parent = widget; } else { localPostion = worldPostion; return; } float x = 0, y = 0; var tempParent = parent; while (tempParent != null) { x += tempParent.localPostion.x; y += tempParent.localPostion.y; tempParent = tempParent.Parent; } localPostion.x = worldPostion.x - x; localPostion.y = worldPostion.y - y; RefreshArea(); }
public void AddGUIWidget(EditorGUIWidget widget) { widget.GUISource = this; mAllWidgets.Add(widget); }
public void RemoveChild(EditorGUIWidget widget) { childList.Remove(widget); }
protected void SetParent(EditorGUIWidget widget) { if (parent == widget || this == widget) return; if (parent != null) { parent.RemoveChild(this); } if (widget != null) { widget.AddChild(this); parent = widget; } else { localPostion = worldPostion; return; } float x = 0, y = 0; var tempParent = parent; while (tempParent != null) { x += tempParent.localPostion.x; y += tempParent.localPostion.y; tempParent = tempParent.Parent; } localPostion.x = worldPostion.x - x; localPostion.y = worldPostion.y - y; RefreshArea(); }
public void AddChild(EditorGUIWidget widget) { if (childList.Contains(widget) == false) childList.Add(widget); }
public void RemoveGUIWidget(EditorGUIWidget widget) { widget.GUISource = null; mAllWidgets.Remove(widget); }
private bool TryGetMouseStayWidget(Vector2 point, out EditorGUIWidget widget) { widget = null; for (int i = mAllWidgets.Count - 1; i >= 0; i--) { if (mAllWidgets[i].IsTrigger == false) continue; if (mAllWidgets[i].AreaRect.Contains(point)) { widget = mAllWidgets[i]; return true; } } return false; }
public void OnGUI() { nowEvent = Event.current; if (mAllWidgets.Count == 0) return; TryGetMouseStayWidget(nowEvent.mousePosition, out pointEnter); if (nowEvent.type == EventType.Ignore) { pointPress = null; pointDrag = null; } if (nowEvent.isMouse) { if (nowEvent.type == EventType.MouseDown) { // 只响应一个button,其余过滤. if (pointPress != null) return; lastPointPress = null; pointPress = pointEnter; if (pointPress != null) Notify(pointPress, EventGUIType.Press, true); } else if (nowEvent.type == EventType.MouseUp) { if (pointPress != null) { if (pointPress == pointEnter && pointPress != pointDrag) { #if GUI_WINDOW_LOG Debug.Log("Click!"); #endif Notify(pointPress, EventGUIType.Click, true); } else { Notify(pointPress, EventGUIType.Press, false); } lastPointPress = pointPress; } pointPress = null; pointDrag = null; } else if (nowEvent.type == EventType.MouseDrag) { if (pointDrag == null) pointDrag = pointPress; #if GUI_WINDOW_LOG Debug.Log("drag1"); #endif if (pointDrag != null) { #if GUI_WINDOW_LOG Debug.Log("drag2"); #endif Notify(pointDrag, EventGUIType.Drag, null); } } } #if GUI_WINDOW_LOG string debugInfo = string.Format("pointEnter {0} | pointPress {1} \n lastPointPress {2} | pointDrag {3}", pointEnter != null ? pointEnter.ToString() : string.Empty, pointPress != null ? pointPress.ToString() : string.Empty, lastPointPress != null ? lastPointPress.ToString() : string.Empty, pointDrag != null ? pointDrag.ToString() : string.Empty); GUILayout.Label(debugInfo); #endif }
public void OnGUI() { nowEvent = Event.current; if (mAllWidgets.Count == 0) { return; } TryGetMouseStayWidget(nowEvent.mousePosition, out pointEnter); if (nowEvent.type == EventType.Ignore) { pointPress = null; pointDrag = null; } if (nowEvent.isMouse) { if (nowEvent.type == EventType.MouseDown) { // 只响应一个button,其余过滤. if (pointPress != null) { return; } lastPointPress = null; pointPress = pointEnter; if (pointPress != null) { Notify(pointPress, EventGUIType.Press, true); } } else if (nowEvent.type == EventType.MouseUp) { if (pointPress != null) { if (pointPress == pointEnter && pointPress != pointDrag) { #if GUI_WINDOW_LOG Debug.Log("Click!"); #endif Notify(pointPress, EventGUIType.Click, true); } else { Notify(pointPress, EventGUIType.Press, false); } lastPointPress = pointPress; } pointPress = null; pointDrag = null; } else if (nowEvent.type == EventType.MouseDrag) { if (pointDrag == null) { pointDrag = pointPress; } #if GUI_WINDOW_LOG Debug.Log("drag1"); #endif if (pointDrag != null) { #if GUI_WINDOW_LOG Debug.Log("drag2"); #endif Notify(pointDrag, EventGUIType.Drag, null); } } } #if GUI_WINDOW_LOG string debugInfo = string.Format("pointEnter {0} | pointPress {1} \n lastPointPress {2} | pointDrag {3}", pointEnter != null ? pointEnter.ToString() : string.Empty, pointPress != null ? pointPress.ToString() : string.Empty, lastPointPress != null ? lastPointPress.ToString() : string.Empty, pointDrag != null ? pointDrag.ToString() : string.Empty); GUILayout.Label(debugInfo); #endif }