|
|
|
|
|
|
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) |
|
|
|