浏览代码
Merge pull request #1512 from Unity-Technologies/sg/update-window-title-when-after-file-rename
Merge pull request #1512 from Unity-Technologies/sg/update-window-title-when-after-file-rename
Update window title/main
GitHub
7 年前
当前提交
630691ab
共有 10 个文件被更改,包括 229 次插入 和 133 次删除
-
1com.unity.shadergraph/CHANGELOG.md
-
12com.unity.shadergraph/Editor/Drawing/Blackboard/BlackboardProvider.cs
-
13com.unity.shadergraph/Editor/Drawing/Inspector/MasterPreviewView.cs
-
25com.unity.shadergraph/Editor/Drawing/MaterialGraphEditWindow.cs
-
17com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs
-
135com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs
-
69com.unity.shadergraph/Editor/Importers/ShaderGraphImporterEditor.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]).Split('/').Last(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
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("shadersubgraph", 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