浏览代码
Added update title to master preview and blackboard.
Added update title to master preview and blackboard.
cleaned up assetName parameter and dded it as a property instead Made a seperate shader graph post processor file/main
Martin Thorzen
7 年前
当前提交
37c00666
共有 12 个文件被更改,包括 234 次插入 和 171 次删除
-
2com.unity.shadergraph/Editor/Data/Graphs/AbstractMaterialGraph.cs
-
12com.unity.shadergraph/Editor/Drawing/Blackboard/BlackboardProvider.cs
-
13com.unity.shadergraph/Editor/Drawing/Inspector/MasterPreviewView.cs
-
53com.unity.shadergraph/Editor/Drawing/MaterialGraphEditWindow.cs
-
17com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs
-
13com.unity.shadergraph/Editor/Drawing/Views/MaterialNodeView.cs
-
135com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs
-
69com.unity.shadergraph/Editor/Importers/ShaderGraphImporterEditor.cs
-
1com.unity.shadergraph/Editor/Importers/ShaderSubGraphImporter.cs
-
17com.unity.shadergraph/Editor/Importers/ShaderSubGraphImporterEditor.cs
-
62com.unity.shadergraph/Editor/Importers/ShaderGraphAssetPostProcessor.cs
-
11com.unity.shadergraph/Editor/Importers/ShaderGraphAssetPostProcessor.cs.meta
|
|||
using UnityEngine; |
|||
using System; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using UnityEditor; |
|||
using UnityEditor.ShaderGraph.Drawing; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
class ShaderGraphAssetPostProcessor : AssetPostprocessor |
|||
{ |
|||
static void RegisterShaders(string[] paths) |
|||
{ |
|||
foreach (var path in paths) |
|||
{ |
|||
if (!path.EndsWith(ShaderGraphImporter.ShaderGraphExtension, StringComparison.InvariantCultureIgnoreCase)) |
|||
continue; |
|||
|
|||
var mainObj = AssetDatabase.LoadMainAssetAtPath(path); |
|||
if (mainObj is Shader) |
|||
ShaderUtil.RegisterShader((Shader)mainObj); |
|||
|
|||
var objs = AssetDatabase.LoadAllAssetRepresentationsAtPath(path); |
|||
foreach (var obj in objs) |
|||
{ |
|||
if (obj is Shader) |
|||
ShaderUtil.RegisterShader((Shader)obj); |
|||
} |
|||
} |
|||
} |
|||
|
|||
static void UpdateAfterAssetChange(string[] newNames) |
|||
{ |
|||
// This will change the title of the window.
|
|||
MaterialGraphEditWindow[] windows = Resources.FindObjectsOfTypeAll<MaterialGraphEditWindow>(); |
|||
foreach (var matGraphEditWindow in windows) |
|||
{ |
|||
for (int i = 0; i < newNames.Length; ++i) |
|||
{ |
|||
if (matGraphEditWindow.selectedGuid == AssetDatabase.AssetPathToGUID(newNames[i])) |
|||
matGraphEditWindow.assetName = Path.GetFileNameWithoutExtension(newNames[i]); |
|||
} |
|||
} |
|||
} |
|||
|
|||
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) |
|||
{ |
|||
MaterialGraphEditWindow[] windows = Resources.FindObjectsOfTypeAll<MaterialGraphEditWindow>(); |
|||
foreach (var matGraphEditWindow in windows) |
|||
{ |
|||
matGraphEditWindow.forceRedrawPreviews = true; |
|||
} |
|||
|
|||
RegisterShaders(importedAssets); |
|||
|
|||
bool anyShaders = movedAssets.Any(val => val.EndsWith(ShaderGraphImporter.ShaderGraphExtension, StringComparison.InvariantCultureIgnoreCase)); |
|||
anyShaders |= movedAssets.Any(val => val.EndsWith(ShaderSubGraphImporter.ShaderSubGraphExtension, StringComparison.InvariantCultureIgnoreCase)); |
|||
if (anyShaders) |
|||
UpdateAfterAssetChange(movedAssets); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c6721e5578adf964fa914cf0d66e0bdb |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue