浏览代码

Merge pull request #258 from Unity-Technologies/fix-postlayoutevent

Fixes for PostLayoutEvent changes
/main
GitHub 7 年前
当前提交
e818e796
共有 2 个文件被更改,包括 17 次插入28 次删除
  1. 43
      com.unity.shadergraph/Editor/Drawing/Manipulators/WindowDraggable.cs
  2. 2
      com.unity.shadergraph/Editor/Drawing/Views/MaterialGraphView.cs

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


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

{
public class WindowDraggable : MouseManipulator
{
bool m_ResizeWithParentWindow;
bool m_Active;
WindowDockingLayout m_WindowDockingLayout;

VisualElement m_Handle;
GraphView m_GraphView;
public WindowDraggable(VisualElement handle = null, bool resizeWithParentwindow = false)
public WindowDraggable(VisualElement handle = null)
m_ResizeWithParentWindow = resizeWithParentwindow;
m_Active = false;
m_PreviousParentRect = new Rect(0f, 0f, 0f, 0f);
m_WindowDockingLayout = new WindowDockingLayout();

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);
target.UnregisterCallback<GeometryChangedEvent>(InitialLayoutSetup);
target.UnregisterCallback<GeometryChangedEvent>(OnGeometryChanged);
if (m_GraphView != null)
m_GraphView.UnregisterCallback<GeometryChangedEvent>(OnGeometryChanged);
}
void OnMouseDown(MouseDownEvent evt)

target.UnregisterCallback<GeometryChangedEvent>(InitialLayoutSetup);
target.RegisterCallback<GeometryChangedEvent>(OnGeometryChanged);
VisualElement parent = target.parent;
while (parent != null && !(parent is GraphView))
parent = parent.parent;
m_GraphView = parent as GraphView;
if (m_GraphView != null)
m_GraphView.RegisterCallback<GeometryChangedEvent>(OnGeometryChanged);
m_WindowDockingLayout.CalculateDockingCornerAndOffset(target.layout, target.parent.layout);
}

Vector2 scaling = target.parent.layout.size / m_PreviousParentRect.size;
Vector2 minSize = new Vector2(60f, 60f);

Vector2 distanceFromParentEdge = Vector2.zero;
distanceFromParentEdge.x = m_WindowDockingLayout.dockingLeft ? target.layout.x : (m_PreviousParentRect.width - target.layout.x - target.layout.width);
distanceFromParentEdge.y = m_WindowDockingLayout.dockingTop ? target.layout.y: (m_PreviousParentRect.height - target.layout.y - target.layout.height);
distanceFromParentEdge.y = m_WindowDockingLayout.dockingTop ? target.layout.y : (m_PreviousParentRect.height - target.layout.y - target.layout.height);
Vector2 normalizedDistanceFromEdge = distanceFromParentEdge / m_PreviousParentRect.size;
if (m_ResizeWithParentWindow)
{
if (scaling.x > 1f)
{
scaling.x = target.parent.layout.width * .33f < minSize.x ? 1f : scaling.x;
}
if (scaling.y > 1f)
{
scaling.y = target.parent.layout.height * .33f < minSize.y ? 1f : scaling.y;
}
windowRect.size *= scaling;
}
else
{
normalizedDistanceFromEdge = distanceFromParentEdge / target.parent.layout.size;
}
Vector2 normalizedDistanceFromEdge = distanceFromParentEdge / target.parent.layout.size;
if (m_WindowDockingLayout.dockingLeft)
{

2
com.unity.shadergraph/Editor/Drawing/Views/MaterialGraphView.cs


graph.RemoveShaderProperty(property.guid);
}
}
selection.Clear();
}

正在加载...
取消
保存