浏览代码
- Remove NodeCreator
- Remove NodeCreator
- Derive Port so that we can use our own IEdgeConnectorListener - Handle element removal event from GraphView/main
Peter Bay Bastian
7 年前
当前提交
09db5bd9
共有 10 个文件被更改,包括 267 次插入 和 49 次删除
-
15MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs
-
1MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs
-
192MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/EdgeConnectorListener.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/EdgeConnectorListener.cs.meta
-
22MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/ShaderPort.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/ShaderPort.cs.meta
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/NodeCreator.cs.meta
-
40MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/NodeCreator.cs
|
|||
using UnityEditor.Experimental.UIElements.GraphView; |
|||
using UnityEditor.Graphing; |
|||
using UnityEngine; |
|||
using Edge = UnityEditor.Experimental.UIElements.GraphView.Edge; |
|||
|
|||
namespace UnityEditor.ShaderGraph.Drawing |
|||
{ |
|||
public class EdgeConnectorListener : IEdgeConnectorListener |
|||
{ |
|||
readonly AbstractMaterialGraph m_Graph; |
|||
|
|||
public EdgeConnectorListener(AbstractMaterialGraph graph) |
|||
{ |
|||
m_Graph = graph; |
|||
} |
|||
|
|||
public void OnDropOutsidePort(Edge edge, Vector2 position) |
|||
{ |
|||
} |
|||
|
|||
public void OnDrop(GraphView graphView, Edge edge) |
|||
{ |
|||
var leftSlot = edge.output.userData as ISlot; |
|||
var rightSlot = edge.input.userData as ISlot; |
|||
if (leftSlot != null && rightSlot != null) |
|||
{ |
|||
m_Graph.Connect(leftSlot.slotReference, rightSlot.slotReference); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 36c61698900b42c9a6b5e28c3651249a |
|||
timeCreated: 1512740035 |
|
|||
using System; |
|||
using UnityEditor.Experimental.UIElements.GraphView; |
|||
using UnityEngine.Experimental.UIElements; |
|||
|
|||
namespace UnityEditor.ShaderGraph.Drawing |
|||
{ |
|||
sealed class ShaderPort : Port |
|||
{ |
|||
ShaderPort(Orientation portOrientation, Direction portDirection, Type type) |
|||
: base(portOrientation, portDirection, type) { } |
|||
|
|||
public static Port Create(Orientation orientation, Direction direction, Type type, IEdgeConnectorListener connectorListener) |
|||
{ |
|||
var port = new ShaderPort(orientation, direction, type) |
|||
{ |
|||
m_EdgeConnector = new EdgeConnector<Edge>(connectorListener), |
|||
}; |
|||
port.AddManipulator(port.m_EdgeConnector); |
|||
return port; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 96f5a3d0303d4d9395a450dcce906110 |
|||
timeCreated: 1512739794 |
|
|||
fileFormatVersion: 2 |
|||
guid: 48d2349cc7ed41d9bf77231b69efbc05 |
|||
timeCreated: 1508752297 |
|
|||
using System; |
|||
using System.Linq; |
|||
using System.Reflection; |
|||
using UnityEditor.Experimental.UIElements.GraphView; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.UIElements; |
|||
using UnityEditor.ShaderGraph; |
|||
|
|||
namespace UnityEditor.ShaderGraph.Drawing |
|||
{ |
|||
public class NodeCreator : MouseManipulator |
|||
{ |
|||
SearchWindowProvider m_SearchWindowProvider; |
|||
|
|||
public NodeCreator(SearchWindowProvider searchWindowProvider) |
|||
{ |
|||
m_SearchWindowProvider = searchWindowProvider; |
|||
activators.Add(new ManipulatorActivationFilter { button = MouseButton.RightMouse }); |
|||
} |
|||
|
|||
protected override void RegisterCallbacksOnTarget() |
|||
{ |
|||
target.RegisterCallback<MouseUpEvent>(OnMouseUp); |
|||
} |
|||
|
|||
void OnMouseUp(MouseUpEvent evt) |
|||
{ |
|||
if (CanStartManipulation(evt)) |
|||
{ |
|||
SearchWindow.Open(new SearchWindowContext(GUIUtility.GUIToScreenPoint(evt.mousePosition)), m_SearchWindowProvider); |
|||
evt.StopPropagation(); |
|||
} |
|||
} |
|||
|
|||
protected override void UnregisterCallbacksFromTarget() |
|||
{ |
|||
target.UnregisterCallback<MouseUpEvent>(OnMouseUp); |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue