浏览代码

Store master node preview mesh in GraphInspectorView persistent data

/main
Jens Holm 7 年前
当前提交
c3f4ae78
共有 1 个文件被更改,包括 37 次插入3 次删除
  1. 40
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs

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


using UnityEngine.Experimental.UIElements;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph;
using UnityEngine.AI;
[Serializable]
class PersistentMesh
{
[SerializeField]
Mesh m_Mesh;
public Mesh mesh
{
get { return m_Mesh; }
set { m_Mesh = value; }
}
}
public class GraphInspectorView : VisualElement, IDisposable
{
int m_SelectionHash;

List<INode> m_SelectedNodes;
PersistentMesh m_PersistentMasterNodePreviewMesh;
persistenceKey = "GraphInspector";
m_Graph = graph;
m_PreviewManager = previewManager;
m_SelectedNodes = new List<INode>();

m_PreviewMeshPicker = new ObjectField() { objectType = typeof(Mesh) };
m_PreviewMeshPicker.OnValueChanged(OnPreviewMeshChanged);
bottomContainer.Add(m_PreviewMeshPicker);
}
Add(bottomContainer);

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

if (changeEvent.newValue == null)
{
m_PreviewHandle.mesh = null;
return;
m_PersistentMasterNodePreviewMesh.mesh = null;
}
Mesh changedMesh = changeEvent.newValue as Mesh;

m_PreviewHandle.mesh = changedMesh;
m_PersistentMasterNodePreviewMesh.mesh = changedMesh;
masterNode.onModified(masterNode, ModificationScope.Node);
SavePersistentData();
}
public override void OnPersistentDataReady()
{
base.OnPersistentDataReady();
string key = GetFullHierarchicalPersistenceKey();
m_PersistentMasterNodePreviewMesh = GetOrCreatePersistentData<PersistentMesh>(m_PersistentMasterNodePreviewMesh, key);
m_PreviewMeshPicker.SetValueAndNotify(m_PersistentMasterNodePreviewMesh.mesh);
}
public void UpdateSelection(IEnumerable<INode> nodes)

正在加载...
取消
保存