Unity 删除Shader默认材质,防止打包反向引用
2024/06
07
18:06
using UnityEditor;
using UnityEngine;
public static class StripShaderDefaultTextures
{
private static string[] kEmptyNames = new string[0];
private static Texture[] kEmtpyTextures = new Texture[0];
[MenuItem("Tools/删除所有Shader的默认纹理")]
public static void StripAllShaderDefaultTextures()
{
var allShaders = AssetDatabase.FindAssets("t:Shader");
foreach(var guid in allShaders)
{
string assetPath = AssetDatabase.GUIDToAssetPath(guid);
ShaderImporter shaderImporter = ShaderImporter.GetAtPath(assetPath) as ShaderImporter;
if (shaderImporter != null)
{
shaderImporter.SetDefaultTextures(kEmptyNames, kEmtpyTextures);
shaderImporter.SaveAndReimport();
}
}
}
}
CopyRights: The Post by BY-NC-SA For Authorization,Original If Not Noted,Reprint Please Indicate From 老刘@开发笔记
Post Link: Unity 删除Shader默认材质,防止打包反向引用
Post Link: Unity 删除Shader默认材质,防止打包反向引用