浏览代码

Merge branch 'master' into no-presenters

/main
damian 7 年前
当前提交
6a03177d
共有 2 个文件被更改,包括 35 次插入23 次删除
  1. 6
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableGraphObject.cs
  2. 52
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs

6
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableGraphObject.cs


public void OnBeforeSerialize()
{
m_SerializedGraph = SerializationHelper.Serialize(graph);
if (graph != null)
m_SerializedGraph = SerializationHelper.Serialize(graph);
}
public void OnAfterDeserialize()

graph = m_DeserializedGraph;
graph = deserializedGraph;
else
m_DeserializedGraph = deserializedGraph; // graph.ReplaceWith(m_DeserializedGraph);
}

Undo.undoRedoPerformed += UndoRedoPerformed;
UndoRedoPerformed();
}
void OnDisable()

52
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs


{
public override AbstractMaterialGraph GetMaterialGraph()
{
return inMemoryAsset.graph as AbstractMaterialGraph;
return graphObject == null ? null : graphObject.graph as AbstractMaterialGraph;
}
}

{
return inMemoryAsset.graph as AbstractMaterialGraph;
return graphObject == null ? null : graphObject.graph as AbstractMaterialGraph;
}
}

{
return inMemoryAsset.graph as AbstractMaterialGraph;
return graphObject == null ? null : graphObject.graph as AbstractMaterialGraph;
}
}

Object m_Selected;
[SerializeField]
SerializableGraphObject m_InMemoryAsset;
SerializableGraphObject m_GraphObject;
GraphEditorView m_GraphEditorView;
GraphEditorView graphEditorView

}
}
protected SerializableGraphObject inMemoryAsset
protected SerializableGraphObject graphObject
get { return m_InMemoryAsset; }
get { return m_GraphObject; }
if (m_InMemoryAsset != null)
DestroyImmediate(m_InMemoryAsset);
m_InMemoryAsset = value;
if (m_GraphObject != null)
DestroyImmediate(m_GraphObject);
m_GraphObject = value;
}
}

void Update()
{
var materialGraph = GetMaterialGraph();
if (materialGraph == null)
return;
graphEditorView = new GraphEditorView(GetMaterialGraph(), this, selected.name);
{
graphEditorView = new GraphEditorView(materialGraph, this, selected.name);
}
if (graphEditorView != null)
graphEditorView.previewSystem.Update();
}

{
UpdateAsset();
}
DestroyImmediate(inMemoryAsset);
Undo.ClearUndo(graphObject);
DestroyImmediate(graphObject);
if (graphEditorView == null)
return;
var presenter = graphEditorView.graphPresenter;
var e = Event.current;

public override void UpdateAsset()
{
if (selected != null && inMemoryAsset != null)
if (selected != null && graphObject != null)
if (string.IsNullOrEmpty(path) || inMemoryAsset == null)
if (string.IsNullOrEmpty(path) || graphObject == null)
{
return;
}

private void UpdateAbstractSubgraphOnDisk<T>(string path) where T : AbstractSubGraph
{
var graph = inMemoryAsset as T;
var graph = graphObject as T;
File.WriteAllText(path, EditorJsonUtility.ToJson(inMemoryAsset, true));
File.WriteAllText(path, EditorJsonUtility.ToJson(graphObject, true));
var graph = inMemoryAsset.graph as UnityEngine.MaterialGraph.MaterialGraph;
var graph = graphObject.graph as UnityEngine.MaterialGraph.MaterialGraph;
if (graph == null)
return;

textures.Add(texture);
}
shaderImporter.SetNonModifiableTextures(textureNames.ToArray(), textures.ToArray());
File.WriteAllText(path, EditorJsonUtility.ToJson(inMemoryAsset, true));
File.WriteAllText(path, EditorJsonUtility.ToJson(graphObject, true));
shaderImporter.SaveAndReimport();
AssetDatabase.ImportAsset(path);
}

var path = AssetDatabase.GetAssetPath(newSelection);
var textGraph = File.ReadAllText(path, Encoding.UTF8);
inMemoryAsset = CreateInstance<SerializableGraphObject>();
inMemoryAsset.graph = JsonUtility.FromJson<TGraphType>(textGraph);
inMemoryAsset.graph.OnEnable();
inMemoryAsset.graph.ValidateGraph();
graphObject = CreateInstance<SerializableGraphObject>();
graphObject.hideFlags = HideFlags.HideAndDontSave;
graphObject.graph = JsonUtility.FromJson<TGraphType>(textGraph);
graphObject.graph.OnEnable();
graphObject.graph.ValidateGraph();
graphEditorView = new GraphEditorView(GetMaterialGraph(), this, selected.name);
titleContent = new GUIContent(selected.name);

正在加载...
取消
保存