Peter Bay Bastian
7 年前
当前提交
145b4d5f
共有 4 个文件被更改,包括 53 次插入 和 203 次删除
-
129MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs
-
21MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorPresenter.cs.meta
-
94MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorPresenter.cs
|
|||
fileFormatVersion: 2 |
|||
guid: d8c67032914554203be73439532c83b8 |
|||
timeCreated: 1502956093 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using UnityEngine; |
|||
using UnityEngine.Graphing; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing.Inspector |
|||
{ |
|||
public class GraphInspectorPresenter : ScriptableObject, IDisposable |
|||
{ |
|||
PreviewData m_PreviewHandle; |
|||
|
|||
public string assetName { get; set; } |
|||
|
|||
public List<INode> selectedNodes { get; set; } |
|||
|
|||
public Texture previewTexture { get; private set; } |
|||
|
|||
[SerializeField] |
|||
private int m_Version; |
|||
|
|||
[Flags] |
|||
public enum ChangeType |
|||
{ |
|||
Graph = 1 << 0, |
|||
SelectedNodes = 1 << 1, |
|||
AssetName = 1 << 2, |
|||
PreviewTexture = 1 << 3, |
|||
All = -1 |
|||
} |
|||
|
|||
public delegate void OnChange(ChangeType changeType); |
|||
|
|||
public OnChange onChange; |
|||
|
|||
[SerializeField] |
|||
private HelperMaterialGraphEditWindow m_Owner; |
|||
|
|||
public AbstractMaterialGraph graph |
|||
{ |
|||
get { return m_Owner.GetMaterialGraph(); } |
|||
} |
|||
|
|||
public void Dirty() |
|||
{ |
|||
m_Version++; |
|||
} |
|||
|
|||
public void Initialize(string assetName, PreviewSystem previewSystem, HelperMaterialGraphEditWindow window) |
|||
{ |
|||
m_Owner = window; |
|||
var masterNode = graph.GetNodes<MasterNode>().FirstOrDefault(); |
|||
if (masterNode != null) |
|||
{ |
|||
m_PreviewHandle = previewSystem.GetPreview(masterNode); |
|||
m_PreviewHandle.onPreviewChanged += OnPreviewChanged; |
|||
} |
|||
this.assetName = assetName; |
|||
selectedNodes = new List<INode>(); |
|||
|
|||
NotifyChange(ChangeType.Graph | ChangeType.SelectedNodes | ChangeType.AssetName); |
|||
} |
|||
|
|||
void OnPreviewChanged() |
|||
{ |
|||
previewTexture = m_PreviewHandle.texture; |
|||
NotifyChange(ChangeType.PreviewTexture); |
|||
} |
|||
|
|||
public void UpdateSelection(IEnumerable<INode> nodes) |
|||
{ |
|||
selectedNodes.Clear(); |
|||
selectedNodes.AddRange(nodes); |
|||
|
|||
NotifyChange(ChangeType.SelectedNodes); |
|||
} |
|||
|
|||
void NotifyChange(ChangeType changeType) |
|||
{ |
|||
if (onChange != null) |
|||
onChange(changeType); |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
if (m_PreviewHandle != null) |
|||
{ |
|||
m_PreviewHandle.onPreviewChanged -= OnPreviewChanged; |
|||
m_PreviewHandle = null; |
|||
}; |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue