Peter Bay Bastian
7 年前
当前提交
ecb231e6
共有 4 个文件被更改,包括 63 次插入 和 109 次删除
-
78MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphInspector.cs
-
10MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Resources.meta
-
72MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractGraphInspector.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractGraphInspector.cs.meta
|
|||
fileFormatVersion: 2 |
|||
guid: abb5ef211431d3a40807d20387f72d57 |
|||
folderAsset: yes |
|||
timeCreated: 1485544540 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using UnityEditor.Graphing.Util; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEditor.Graphing.Drawing |
|||
{ |
|||
public abstract class AbstractGraphInspector : Editor |
|||
{ |
|||
private ScriptableObjectFactory<INode, AbstractNodeInspector, BasicNodeInspector> m_InspectorFactory; |
|||
|
|||
private List<INode> m_SelectedNodes = new List<INode>(); |
|||
|
|||
protected IEnumerable<INode> selectedNodes |
|||
{ |
|||
get { return m_SelectedNodes; } |
|||
} |
|||
|
|||
private List<AbstractNodeInspector> m_Inspectors = new List<AbstractNodeInspector>(); |
|||
|
|||
protected IGraphAsset graphAsset |
|||
{ |
|||
get { return target as IGraphAsset; } |
|||
} |
|||
|
|||
protected AbstractGraphInspector(IEnumerable<TypeMapping> typeMappings) |
|||
{ |
|||
m_InspectorFactory = new ScriptableObjectFactory<INode, AbstractNodeInspector, BasicNodeInspector>(typeMappings); |
|||
} |
|||
|
|||
public override void OnInspectorGUI() |
|||
{ |
|||
UpdateSelection(); |
|||
|
|||
foreach (var inspector in m_Inspectors) |
|||
{ |
|||
inspector.OnInspectorGUI(); |
|||
} |
|||
} |
|||
|
|||
private void UpdateSelection() |
|||
{ |
|||
if (graphAsset == null) |
|||
return; |
|||
|
|||
using (var nodes = ListPool<INode>.GetDisposable()) |
|||
{ |
|||
nodes.value.AddRange(graphAsset.drawingData.selection.Select(graphAsset.graph.GetNodeFromGuid)); |
|||
if (m_SelectedNodes == null || m_Inspectors.Any(i => i.node == null) || !nodes.value.SequenceEqual(m_SelectedNodes)) |
|||
OnSelectionChanged(nodes.value); |
|||
} |
|||
} |
|||
|
|||
protected virtual void OnSelectionChanged(IEnumerable<INode> selectedNodes) |
|||
{ |
|||
m_SelectedNodes.Clear(); |
|||
m_SelectedNodes.AddRange(selectedNodes); |
|||
m_Inspectors.Clear(); |
|||
foreach (var node in m_SelectedNodes.OfType<SerializableNode>()) |
|||
{ |
|||
var inspector = m_InspectorFactory.Create(node); |
|||
inspector.Initialize(node); |
|||
m_Inspectors.Add(inspector); |
|||
} |
|||
} |
|||
|
|||
public virtual void OnEnable() |
|||
{ |
|||
UpdateSelection(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0e3ca0203324c4b0791cb3c1a53eeecb |
|||
timeCreated: 1482322349 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue