浏览代码

Make blackboard only be draggable from the header to avoid conflicts with fields

/main
Peter Bay Bastian 7 年前
当前提交
2fc16a9a
共有 2 个文件被更改,包括 20 次插入15 次删除
  1. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Blackboard/BlackboardProvider.cs
  2. 33
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/WindowDraggable.cs

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Blackboard/BlackboardProvider.cs


moveItemRequested = MoveItemRequested
};
m_WindowDraggable = new WindowDraggable();
m_WindowDraggable = new WindowDraggable(blackboard.shadow.Children().First().Q("header"));
blackboard.AddManipulator(m_WindowDraggable);
m_ResizeBorderFrame = new ResizeBorderFrame(blackboard) { name = "resizeBorderFrame" };

33
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/WindowDraggable.cs


using System;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

Vector2 m_LocalMosueOffset;
Rect m_PreviousParentRect;
VisualElement m_Handle;
public WindowDraggable(bool resizeWithParentwindow = false)
public WindowDraggable(VisualElement handle = null, bool resizeWithParentwindow = false)
m_Handle = handle;
m_ResizeWithParentWindow = resizeWithParentwindow;
m_Active = false;
m_PreviousParentRect = new Rect(0f, 0f, 0f, 0f);

{
target.RegisterCallback(new EventCallback<MouseDownEvent>(OnMouseDown), Capture.NoCapture);
target.RegisterCallback(new EventCallback<MouseMoveEvent>(OnMouseMove), Capture.NoCapture);
target.RegisterCallback(new EventCallback<MouseUpEvent>(OnMouseUp), Capture.NoCapture);
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);
target.UnregisterCallback(new EventCallback<MouseDownEvent>(OnMouseDown), Capture.NoCapture);
target.UnregisterCallback(new EventCallback<MouseMoveEvent>(OnMouseMove), Capture.NoCapture);
target.UnregisterCallback(new EventCallback<MouseUpEvent>(OnMouseUp), Capture.NoCapture);
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_LocalMosueOffset = target.WorldToLocal(evt.mousePosition);
m_LocalMosueOffset = m_Handle.WorldToLocal(evt.mousePosition);
target.TakeMouseCapture();
evt.StopPropagation();
m_Handle.TakeMouseCapture();
evt.StopImmediatePropagation();
}
void OnMouseMove(MouseMoveEvent evt)

m_Active = false;
if (target.HasMouseCapture())
if (m_Handle.HasMouseCapture())
target.ReleaseMouseCapture();
m_Handle.ReleaseMouseCapture();
evt.StopPropagation();
evt.StopImmediatePropagation();
RefreshDocking();

正在加载...
取消
保存