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