浏览代码

Merge pull request #191 from Unity-Technologies/fixes-for-blackboard

Fixes for blackboard
/main
GitHub 7 年前
当前提交
86e92a04
共有 3 个文件被更改,包括 24 次插入17 次删除
  1. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Blackboard/BlackboardField.cs
  2. 5
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Blackboard/BlackboardProvider.cs
  3. 33
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/WindowDraggable.cs

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Blackboard/BlackboardField.cs


activeFieldInfo.SetValue(m_SelectionDropper, false);
this.AddManipulator(m_SelectionDropper);
var contextualMenuManipulator = (IManipulator)Activator.CreateInstance(s_ContextualMenuManipulator, (Action<ContextualMenuPopulateEvent>)BuildContextualMenu);
this.AddManipulator(contextualMenuManipulator);
this.AddManipulator((IManipulator)Activator.CreateInstance(s_ContextualMenuManipulator, (Action<ContextualMenuPopulateEvent>)BuildContextualMenu));
}
void BuildContextualMenu(ContextualMenuPopulateEvent evt)

5
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" };

var property = visualElement.userData as IShaderProperty;
if (property == null)
return;
m_Graph.owner.RegisterCompleteObjectUndo("Move Property");
m_Graph.MoveShaderProperty(property, newIndex);
}

var property = (IShaderProperty)field.userData;
if (newText != property.displayName)
{
m_Graph.owner.RegisterCompleteObjectUndo("Edit Property Name");
property.displayName = newText;
field.text = newText;
DirtyNodes();

{
field.RenameGo();
row.expanded = true;
m_Graph.owner.RegisterCompleteObjectUndo("Create Property");
m_Graph.AddShaderProperty(property);
}
}

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();

正在加载...
取消
保存