Files
MinFt/Client/LocalPackages/SoftMaskForUGUI-3.5.0/Editor/Internal/ShaderPreProcessorBase.cs
Liubing\LB 3d8d4d18f3 first commit
先修复一下,错误的场景

删除不必要的钓场资产

修复into场景

update:更新meta文件,修复报错

update:修复资源

修复第一章节建造

修复建造第三章

update:删除多余内容

update:更新README.md

update:还原图标

update:更新README

update:更新配置
2026-04-28 02:17:22 +08:00

64 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor.Build;
using UnityEditor.Rendering;
using UnityEngine;
#if !UNITY_2021_2_OR_NEWER
using UnityEngine.Rendering;
#endif
namespace Coffee.UISoftMaskInternal
{
internal abstract class ShaderPreProcessorBase : IPreprocessShaders
{
public abstract int callbackOrder { get; }
public abstract void OnProcessShader(Shader shader, ShaderSnippetData snippet, IList<ShaderCompilerData> data);
protected static void Log(Shader shader, IList<ShaderCompilerData> data, IEnumerable<string> ignoredKeywords)
{
Console.WriteLine($"[{shader.name}] {data.Count} variants available:");
foreach (var (platform, keywords) in data
.Select(d => (d.shaderCompilerPlatform, GetKeyWords(shader, d, ignoredKeywords)))
.OrderBy(t => t.Item2))
{
Console.WriteLine($" - {platform}: {keywords}");
}
Console.WriteLine();
}
protected static void StripUnusedVariantsIf(IList<ShaderCompilerData> data, bool condition)
{
if (condition)
{
data.Clear();
}
}
protected static void StripUnusedVariantsIf(IList<ShaderCompilerData> data, Predicate<ShaderCompilerData> pred)
{
for (var i = data.Count - 1; i >= 0; --i)
{
if (pred(data[i]))
{
data.RemoveAt(i);
}
}
}
private static string GetKeyWords(Shader shader, ShaderCompilerData data, IEnumerable<string> ignoredKeywords)
{
return string.Join("|", data.shaderKeywordSet.GetShaderKeywords()
#if UNITY_2021_2_OR_NEWER
.Select(x => x.name)
#else
.Select(x => ShaderKeyword.GetKeywordName(shader, x))
#endif
.Where(k => ignoredKeywords == null || !ignoredKeywords.Contains(k))
.OrderBy(k => k));
}
}
}