浏览代码

Reuse editor window for a graph if the window is already open.

/main
Tim Cooper 8 年前
当前提交
761baa4b
共有 1 个文件被更改,包括 32 次插入8 次删除
  1. 40
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporter.cs

40
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporter.cs


using System.Collections.Generic;
using System.IO;
using System.Text;
using JetBrains.Annotations;
using Object = UnityEngine.Object;
class ShaderGraphTextGenerator : ICustomShaderImporter
{

return false;
}
public void OnInspectorGUI(string path, UnityAction defaultOnInspectorGUI)
public void OpenAsset(string path)
{
ShowGraphEditWindow(path);
}
public void OnInspectorGUI(string path, [NotNull] UnityAction defaultOnInspectorGUI)
if (defaultOnInspectorGUI == null)
throw new ArgumentNullException("defaultOnInspectorGUI");
var window = new MaterialGraphEditWindow();
window.Show();
window.ChangeSelction(AssetDatabase.LoadAssetAtPath<Shader>(path));
ShowGraphEditWindow(path);
public void OpenAsset(string path)
private static void ShowGraphEditWindow(string path)
var window = new MaterialGraphEditWindow();
window.Show();
window.ChangeSelction(AssetDatabase.LoadAssetAtPath<Shader>(path));
var asset = AssetDatabase.LoadAssetAtPath<Shader>(path);
var windows = Resources.FindObjectsOfTypeAll<MaterialGraphEditWindow>();
bool foundWindow = false;
foreach (var w in windows)
{
if (w.selected == asset)
{
foundWindow = true;
w.Focus();
}
}
if (!foundWindow)
{
var window = ScriptableObject.CreateInstance<MaterialGraphEditWindow>();
window.Show();
window.ChangeSelction(asset);
}
}
}
正在加载...
取消
保存