浏览代码

Capturemouse event and trickle down enum has changed and this is a fix for that so it is compatible with older versions.

/main
Martin Thorzen 7 年前
当前提交
3a802291
共有 4 个文件被更改,包括 42 次插入18 次删除
  1. 16
      com.unity.shadergraph/Editor/Drawing/Manipulators/Draggable.cs
  2. 4
      com.unity.shadergraph/Editor/Drawing/Manipulators/ResizeSideHandle.cs
  3. 17
      com.unity.shadergraph/Editor/Drawing/Manipulators/WindowDraggable.cs
  4. 23
      com.unity.shadergraph/Editor/Util/CompatibilityExtensions.cs

16
com.unity.shadergraph/Editor/Drawing/Manipulators/Draggable.cs


protected override void RegisterCallbacksOnTarget()
{
target.RegisterCallback(new EventCallback<MouseDownEvent>(OnMouseDown), Capture.NoCapture);
target.RegisterCallback(new EventCallback<MouseMoveEvent>(OnMouseMove), Capture.NoCapture);
target.RegisterCallback(new EventCallback<MouseUpEvent>(OnMouseUp), Capture.NoCapture);
target.RegisterCallback(new EventCallback<MouseDownEvent>(OnMouseDown), TrickleDownEnum.NoTrickleDown);
target.RegisterCallback(new EventCallback<MouseMoveEvent>(OnMouseMove), TrickleDownEnum.NoTrickleDown);
target.RegisterCallback(new EventCallback<MouseUpEvent>(OnMouseUp), TrickleDownEnum.NoTrickleDown);
target.UnregisterCallback(new EventCallback<MouseDownEvent>(OnMouseDown), Capture.NoCapture);
target.UnregisterCallback(new EventCallback<MouseMoveEvent>(OnMouseMove), Capture.NoCapture);
target.UnregisterCallback(new EventCallback<MouseUpEvent>(OnMouseUp), Capture.NoCapture);
target.UnregisterCallback(new EventCallback<MouseDownEvent>(OnMouseDown), TrickleDownEnum.NoTrickleDown);
target.UnregisterCallback(new EventCallback<MouseMoveEvent>(OnMouseMove), TrickleDownEnum.NoTrickleDown);
target.UnregisterCallback(new EventCallback<MouseUpEvent>(OnMouseUp), TrickleDownEnum.NoTrickleDown);
target.TakeMouseCapture();
target.CaptureMouse();
m_Active = true;
evt.StopPropagation();
}

if (target.HasMouseCapture())
{
target.ReleaseMouseCapture();
target.ReleaseMouse();
}
evt.StopPropagation();

4
com.unity.shadergraph/Editor/Drawing/Manipulators/ResizeSideHandle.cs


m_ResizeBeginMousePosition = mouseDownEvent.mousePosition;
m_Dragging = true;
this.TakeMouseCapture();
this.CaptureMouse();
mouseDownEvent.StopPropagation();
}

if (this.HasMouseCapture())
this.ReleaseMouseCapture();
this.ReleaseMouse();
if (OnResizeFinished != null)
OnResizeFinished();

17
com.unity.shadergraph/Editor/Drawing/Manipulators/WindowDraggable.cs


using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine.Experimental.UIElements;
using UnityEngine.Experimental.UIElements.StyleSheets;
#if UNITY_2018_1
using GeometryChangedEvent = UnityEngine.Experimental.UIElements.PostLayoutEvent;
#endif

{
if (m_Handle == null)
m_Handle = target;
m_Handle.RegisterCallback(new EventCallback<MouseDownEvent>(OnMouseDown), Capture.NoCapture);
m_Handle.RegisterCallback(new EventCallback<MouseMoveEvent>(OnMouseMove), Capture.NoCapture);
m_Handle.RegisterCallback(new EventCallback<MouseUpEvent>(OnMouseUp), Capture.NoCapture);
m_Handle.RegisterCallback(new EventCallback<MouseDownEvent>(OnMouseDown), TrickleDownEnum.NoTrickleDown);
m_Handle.RegisterCallback(new EventCallback<MouseMoveEvent>(OnMouseMove), TrickleDownEnum.NoTrickleDown);
m_Handle.RegisterCallback(new EventCallback<MouseUpEvent>(OnMouseUp), TrickleDownEnum.NoTrickleDown);
m_Handle.UnregisterCallback(new EventCallback<MouseDownEvent>(OnMouseDown), Capture.NoCapture);
m_Handle.UnregisterCallback(new EventCallback<MouseMoveEvent>(OnMouseMove), Capture.NoCapture);
m_Handle.UnregisterCallback(new EventCallback<MouseUpEvent>(OnMouseUp), Capture.NoCapture);
m_Handle.UnregisterCallback(new EventCallback<MouseDownEvent>(OnMouseDown), TrickleDownEnum.NoTrickleDown);
m_Handle.UnregisterCallback(new EventCallback<MouseMoveEvent>(OnMouseMove), TrickleDownEnum.NoTrickleDown);
m_Handle.UnregisterCallback(new EventCallback<MouseUpEvent>(OnMouseUp), TrickleDownEnum.NoTrickleDown);
target.UnregisterCallback<GeometryChangedEvent>(OnGeometryChanged);
if (m_GraphView != null)
m_GraphView.UnregisterCallback<GeometryChangedEvent>(OnGeometryChanged);

// to the mouse position.
m_LocalMosueOffset = m_Handle.WorldToLocal(evt.mousePosition);
m_Handle.TakeMouseCapture();
m_Handle.CaptureMouse();
evt.StopImmediatePropagation();
}

if (m_Handle.HasMouseCapture())
{
m_Handle.ReleaseMouseCapture();
m_Handle.ReleaseMouse();
}
evt.StopImmediatePropagation();

23
com.unity.shadergraph/Editor/Util/CompatibilityExtensions.cs


element.Dirty(ChangeType.Repaint);
}
#endif
#if !UNITY_2018_3_OR_NEWER
public static void CaptureMouse(this VisualElement element)
{
element.TakeMouseCapture();
}
public static void ReleaseMouse(this VisualElement element)
{
element.ReleaseMouseCapture();
}
#endif
}
static class TrickleDownEnum
{
#if UNITY_2018_3_OR_NEWER
public static readonly TrickleDown NoTrickleDown = TrickleDown.NoTrickleDown;
public static readonly TrickleDown TrickleDown = TrickleDown.TrickleDown;
#else
public static readonly Capture NoTrickleDown = Capture.NoCapture;
public static readonly Capture TrickleDown = Capture.Capture;
#endif
}
}
正在加载...
取消
保存