using UnityEngine; using UnityEngine.Graphing; using System.Collections.Generic; using UnityEngine.MaterialGraph; namespace UnityEditor.Graphing.Drawing { // TODO JOCE: Should most probably derive from GraphElementPresenter. public class TitleBarDrawData : ScriptableObject { List m_leftItems; List m_rightItems; IGraphAsset m_graphAsset; public IEnumerable leftItems { get { return m_leftItems; } } public IEnumerable rightItems { get { return m_rightItems; } } protected TitleBarDrawData() { } public void Initialize(IGraphAsset graphAsset) { m_graphAsset = graphAsset; m_leftItems = new List(); m_rightItems = new List(); var currentGraphItem = CreateInstance(); currentGraphItem.text = graphAsset != null ? graphAsset.GetScriptableObject().name : ""; m_leftItems.Add(currentGraphItem); var updateAsset = CreateInstance(); updateAsset.text = "Update Asset"; updateAsset.onClick += UpdateAsset; m_leftItems.Add(updateAsset); var showInProjectItem = CreateInstance(); showInProjectItem.text = "Show in project"; showInProjectItem.onClick += OnShowInProjectClick; m_leftItems.Add(showInProjectItem); var optionsItem = CreateInstance(); optionsItem.text = "Options"; m_rightItems.Add(optionsItem); } void OnShowInProjectClick() { if (m_graphAsset != null) EditorGUIUtility.PingObject(m_graphAsset.GetScriptableObject()); } void UpdateAsset() { if (m_graphAsset != null && m_graphAsset is MaterialGraphAsset) { var mg = (MaterialGraphAsset)m_graphAsset; mg.RegenerateInternalShader(); } } } }