浏览代码

PreviewSystem -> PreviewManager

/main
Peter Bay Bastian 7 年前
当前提交
3f1df674
共有 7 个文件被更改,包括 23 次插入23 次删除
  1. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs
  2. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs
  3. 24
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs
  4. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs
  5. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/PreviewManager.cs
  6. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/PreviewManager.cs.meta
  7. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/PreviewManager.cs

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs


PreviewView m_Preview;
AbstractMaterialGraph m_Graph;
PreviewSystem m_PreviewSystem;
PreviewManager m_PreviewManager;
public GraphInspectorView(string assetName, PreviewSystem previewSystem, AbstractMaterialGraph graph)
public GraphInspectorView(string assetName, PreviewManager previewManager, AbstractMaterialGraph graph)
m_PreviewSystem = previewSystem;
m_PreviewManager = previewManager;
m_SelectedNodes = new List<INode>();
AddStyleSheetPath("Styles/MaterialGraph");

m_MasterNode = value;
if (m_MasterNode != null)
{
m_PreviewHandle = m_PreviewSystem.GetPreview(m_MasterNode);
m_PreviewHandle = m_PreviewManager.GetPreview(m_MasterNode);
m_PreviewHandle.mesh = null;
m_PreviewHandle.onPreviewChanged += OnPreviewChanged;
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs


if (graphEditorView == null)
graphEditorView = new GraphEditorView(materialGraph, selected) { persistenceKey = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(selected)) };
graphEditorView.previewSystem.HandleGraphChanges();
graphEditorView.previewSystem.RenderPreviews();
graphEditorView.previewManager.HandleGraphChanges();
graphEditorView.previewManager.RenderPreviews();
graphEditorView.HandleGraphChanges();
graphEditorView.inspectorView.HandleGraphChanges();
graphObject.graph.ClearChanges();

24
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs


ToolbarButtonView m_TimeButton;
ToolbarButtonView m_CopyToClipboardButton;
PreviewSystem m_PreviewSystem;
PreviewManager m_PreviewManager;
public Action onUpdateAssetClick { get; set; }
public Action onConvertToSubgraphClick { get; set; }

public PreviewRate previewRate
{
get { return previewSystem.previewRate; }
set { previewSystem.previewRate = value; }
get { return previewManager.previewRate; }
set { previewManager.previewRate = value; }
public PreviewSystem previewSystem
public PreviewManager previewManager
get { return m_PreviewSystem; }
set { m_PreviewSystem = value; }
get { return m_PreviewManager; }
set { m_PreviewManager = value; }
}
public GraphInspectorView inspectorView

m_Graph = graph;
AddStyleSheetPath("Styles/MaterialGraph");
previewSystem = new PreviewSystem(graph);
previewManager = new PreviewManager(graph);
m_ToolbarView = new ToolbarView { name = "TitleBar" };
{

m_GraphView.AddManipulator(new NodeCreator(graph));
content.Add(m_GraphView);
m_GraphInspectorView = new GraphInspectorView(asset.name, previewSystem, graph) { name = "inspector" };
m_GraphInspectorView = new GraphInspectorView(asset.name, previewManager, graph) { name = "inspector" };
m_GraphView.onSelectionChanged += m_GraphInspectorView.UpdateSelection;
content.Add(m_GraphInspectorView);

void AddNode(INode node)
{
var nodeView = new MaterialNodeView(node as AbstractMaterialNode, m_PreviewSystem) { userData = node };
var nodeView = new MaterialNodeView(node as AbstractMaterialNode, m_PreviewManager) { userData = node };
node.onModified += OnNodeChanged;
m_GraphView.AddElement(nodeView);
}

m_GraphView = null;
}
if (m_GraphInspectorView != null) m_GraphInspectorView.Dispose();
if (previewSystem != null)
if (previewManager != null)
previewSystem.Dispose();
previewSystem = null;
previewManager.Dispose();
previewManager = null;
}
}
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs


VisualElement m_PreviewToggle;
VisualElement m_ControlsContainer;
public MaterialNodeView(AbstractMaterialNode inNode, PreviewSystem previewSystem)
public MaterialNodeView(AbstractMaterialNode inNode, PreviewManager previewManager)
{
AddToClassList("MaterialNode");

pickingMode = PickingMode.Ignore,
image = Texture2D.whiteTexture
};
m_Preview = previewSystem.GetPreview(inNode);
m_Preview = previewManager.GetPreview(inNode);
m_Preview.onPreviewChanged += UpdatePreviewTexture;
UpdatePreviewTexture();
leftContainer.Add(m_PreviewImage);

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/PreviewManager.cs


namespace UnityEditor.MaterialGraph.Drawing
{
public class PreviewSystem : IDisposable
public class PreviewManager : IDisposable
{
AbstractMaterialGraph m_Graph;
Dictionary<Guid, PreviewData> m_Previews = new Dictionary<Guid, PreviewData>();

public PreviewRate previewRate { get; set; }
public PreviewSystem(AbstractMaterialGraph graph)
public PreviewManager(AbstractMaterialGraph graph)
{
m_Graph = graph;
m_PreviewMaterial = new Material(Shader.Find("Unlit/Color")) { hideFlags = HideFlags.HideInHierarchy };

GC.SuppressFinalize(this);
}
~PreviewSystem()
~PreviewManager()
{
ReleaseUnmanagedResources();
}

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/PreviewSystem.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/PreviewManager.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/PreviewSystem.cs → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/PreviewManager.cs

正在加载...
取消
保存