Tim Cooper
7 年前
当前提交
e94975d2
共有 5 个文件被更改,包括 130 次插入 和 128 次删除
-
34MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/MasterRemapGraphImporterEditor.cs
-
116MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporter.cs
-
37MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderSubGraphImporterEditor.cs
-
58MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporterEditor.cs
-
13MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporterEditor.cs.meta
|
|||
using System; |
|||
using System.IO; |
|||
using UnityEditor; |
|||
using UnityEditor.Experimental.AssetImporters; |
|||
using UnityEditor.ShaderGraph; |
|||
using UnityEditor.ShaderGraph.Drawing; |
|||
using UnityEngine; |
|||
using Debug = System.Diagnostics.Debug; |
|||
using Object = UnityEngine.Object; |
|||
|
|||
[CustomEditor(typeof(ShaderGraphImporter))] |
|||
public class ShaderGraphImporterEditor : ScriptedImporterEditor |
|||
{ |
|||
public override void OnInspectorGUI() |
|||
{ |
|||
if (GUILayout.Button("Open Shader Editor")) |
|||
{ |
|||
AssetImporter importer = target as AssetImporter; |
|||
Debug.Assert(importer != null, "importer != null"); |
|||
ShowGraphEditWindow(importer.assetPath); |
|||
} |
|||
} |
|||
|
|||
internal static void ShowGraphEditWindow(string path) |
|||
{ |
|||
var asset = AssetDatabase.LoadAssetAtPath<Object>(path); |
|||
var extension = Path.GetExtension(path); |
|||
Type graphType; |
|||
if (extension == ".ShaderGraph") |
|||
graphType = typeof(MaterialGraph); |
|||
else if (extension == ".LayeredShaderGraph") |
|||
graphType = typeof(LayeredShaderGraph); |
|||
else if (extension == ".ShaderSubGraph") |
|||
graphType = typeof(SubGraph); |
|||
else if (extension == ".ShaderRemapGraph") |
|||
graphType = typeof(MasterRemapGraph); |
|||
else |
|||
return; |
|||
|
|||
var foundWindow = false; |
|||
foreach (var w in Resources.FindObjectsOfTypeAll<MaterialGraphEditWindow>()) |
|||
{ |
|||
if (w.selected == asset) |
|||
{ |
|||
foundWindow = true; |
|||
w.Focus(); |
|||
} |
|||
} |
|||
|
|||
if (!foundWindow) |
|||
{ |
|||
var window = ScriptableObject.CreateInstance<MaterialGraphEditWindow>(); |
|||
window.Show(); |
|||
window.ChangeSelection(asset, graphType); |
|||
} |
|||
} |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 575791f1eb8b54602829004c8bcbe802 |
|||
timeCreated: 1503169819 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue