浏览代码
Implemented copy/paste functionality for graph (currently uses shift rather than ctrl, as the latter does not fire the event)
/main
Implemented copy/paste functionality for graph (currently uses shift rather than ctrl, as the latter does not fire the event)
/main
Peter Bay Bastian
8 年前
当前提交
ce272542
共有 4 个文件被更改,包括 185 次插入 和 2 次删除
-
85MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphDataSource.cs
-
24MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializableGraphView.cs
-
66MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/CopyPasteGraph.cs
-
12MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/CopyPasteGraph.cs.meta
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using UnityEngine; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEditor.Graphing.Util |
|||
{ |
|||
[Serializable] |
|||
internal class CopyPasteGraph : ISerializationCallbackReceiver |
|||
{ |
|||
[NonSerialized] |
|||
private HashSet<IEdge> m_Edges = new HashSet<IEdge>(); |
|||
|
|||
[NonSerialized] |
|||
private HashSet<INode> m_Nodes = new HashSet<INode>(); |
|||
|
|||
[SerializeField] |
|||
List<SerializationHelper.JSONSerializedElement> m_SerializableNodes = new List<SerializationHelper.JSONSerializedElement>(); |
|||
|
|||
[SerializeField] |
|||
List<SerializationHelper.JSONSerializedElement> m_SerializableEdges = new List<SerializationHelper.JSONSerializedElement>(); |
|||
|
|||
public virtual void AddNode(INode node) |
|||
{ |
|||
m_Nodes.Add(node); |
|||
} |
|||
|
|||
public void AddEdge(IEdge edge) |
|||
{ |
|||
m_Edges.Add(edge); |
|||
} |
|||
|
|||
public IEnumerable<T> GetNodes<T>() where T : INode |
|||
{ |
|||
return m_Nodes.OfType<T>(); |
|||
} |
|||
|
|||
public IEnumerable<IEdge> edges |
|||
{ |
|||
get { return m_Edges; } |
|||
} |
|||
|
|||
public virtual void OnBeforeSerialize() |
|||
{ |
|||
m_SerializableNodes = SerializationHelper.Serialize<INode>(m_Nodes); |
|||
m_SerializableEdges = SerializationHelper.Serialize<IEdge>(m_Edges); |
|||
} |
|||
|
|||
public virtual void OnAfterDeserialize() |
|||
{ |
|||
var nodes = SerializationHelper.Deserialize<INode>(m_SerializableNodes, null); |
|||
m_Nodes.Clear(); |
|||
foreach (var node in nodes) |
|||
m_Nodes.Add(node); |
|||
m_SerializableNodes = null; |
|||
|
|||
var edges = SerializationHelper.Deserialize<IEdge>(m_SerializableEdges, null); |
|||
m_Edges.Clear(); |
|||
foreach (var edge in edges) |
|||
m_Edges.Add(edge); |
|||
m_SerializableEdges = null; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 187365d075d49dc46a3e09b81f0d6fdd |
|||
timeCreated: 1483699278 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue