Peter Bay Bastian
7 年前
当前提交
c5a7e594
共有 8 个文件被更改,包括 110 次插入 和 68 次删除
-
2MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableGraph.cs
-
1MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Interfaces/IGraph.cs
-
32MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs
-
64MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
-
65MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableGraphObject.cs
-
3MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableGraphObject.cs.meta
-
8MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Interfaces/IGraphObject.cs
-
3MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Interfaces/IGraphObject.cs.meta
|
|||
using System; |
|||
using UnityEditor; |
|||
|
|||
namespace UnityEngine.Graphing |
|||
{ |
|||
public class SerializableGraphObject : ScriptableObject, IGraphObject, ISerializationCallbackReceiver |
|||
{ |
|||
[SerializeField] |
|||
SerializationHelper.JSONSerializedElement m_SerializedGraph; |
|||
|
|||
IGraph m_Graph; |
|||
IGraph m_DeserializedGraph; |
|||
|
|||
public IGraph graph |
|||
{ |
|||
get { return m_Graph; } |
|||
set |
|||
{ |
|||
if (m_Graph != null) |
|||
m_Graph.owner = null; |
|||
m_Graph = value; |
|||
if (m_Graph != null) |
|||
m_Graph.owner = this; |
|||
} |
|||
} |
|||
|
|||
public void RegisterCompleteObjectUndo(string name) |
|||
{ |
|||
Undo.RegisterCompleteObjectUndo(this, name); |
|||
} |
|||
|
|||
public void OnBeforeSerialize() |
|||
{ |
|||
m_SerializedGraph = SerializationHelper.Serialize(graph); |
|||
} |
|||
|
|||
public void OnAfterDeserialize() |
|||
{ |
|||
var deserializedGraph = SerializationHelper.Deserialize<IGraph>(m_SerializedGraph, null); |
|||
if (graph == null) |
|||
graph = m_DeserializedGraph; |
|||
else |
|||
m_DeserializedGraph = deserializedGraph; // graph.ReplaceWith(m_DeserializedGraph);
|
|||
} |
|||
|
|||
void OnEnable() |
|||
{ |
|||
Undo.undoRedoPerformed += UndoRedoPerformed; |
|||
} |
|||
|
|||
void OnDisable() |
|||
{ |
|||
Undo.undoRedoPerformed -= UndoRedoPerformed; |
|||
} |
|||
|
|||
void UndoRedoPerformed() |
|||
{ |
|||
if (m_DeserializedGraph != null) |
|||
{ |
|||
graph.ReplaceWith(m_DeserializedGraph); |
|||
m_DeserializedGraph = null; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 463ff292c8554dc18fb52fb725707a21 |
|||
timeCreated: 1508144011 |
|
|||
namespace UnityEngine.Graphing |
|||
{ |
|||
public interface IGraphObject |
|||
{ |
|||
IGraph graph { get; set; } |
|||
void RegisterCompleteObjectUndo(string name); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 59661073fa1046e9b3aa3fea5c7f5c54 |
|||
timeCreated: 1508144485 |
撰写
预览
正在加载...
取消
保存
Reference in new issue