浏览代码

Added functionality for updating the title of the shader graph window

/main
Martin Thorzen 7 年前
当前提交
f8fc4b16
共有 1 个文件被更改,包括 33 次插入0 次删除
  1. 33
      com.unity.shadergraph/Editor/Drawing/MaterialGraphEditWindow.cs

33
com.unity.shadergraph/Editor/Drawing/MaterialGraphEditWindow.cs


ColorSpace m_ColorSpace;
static MaterialGraphEditWindow s_Instance;
GraphEditorView m_GraphEditorView;
GraphEditorView graphEditorView

private set { m_Selected = value; }
}
// This is so that we can check if the file on disk has been renamed.
// If it has, we can update the Title of the shader graph tab.
class ShaderPostProcessor : AssetPostprocessor
{
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
if (s_Instance != null)
{
string ending = ".ShaderGraph";
bool anyShaders = importedAssets.Any(val => val.EndsWith(ending));
anyShaders |= movedAssets.Any(val => val.EndsWith(ending));
if (anyShaders)
s_Instance.UpdateAfterAssetChange();
}
}
}
void UpdateAfterAssetChange()
{
var asset = AssetDatabase.LoadAssetAtPath<Object>(AssetDatabase.GUIDToAssetPath(selectedGuid));
if (titleContent.text != asset.name)
titleContent.text = asset.name;
}
public void OnEnable()
{
s_Instance = this;
}
void Update()
{
if (m_HasError)

var materialGraph = graphObject.graph as AbstractMaterialGraph;
if (materialGraph == null)
return;
if (graphEditorView == null)
{
var asset = AssetDatabase.LoadAssetAtPath<Object>(AssetDatabase.GUIDToAssetPath(selectedGuid));

void OnDisable()
{
graphEditorView = null;
s_Instance = null;
}
void OnDestroy()

正在加载...
取消
保存