Files
MinFt/Client/LocalPackages/SoftMaskForUGUI-3.5.0/Runtime/Internal/Utilities/AlwaysIncludedShadersProxy.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

91 lines
2.7 KiB
C#

#if UNITY_EDITOR
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;
namespace Coffee.UISoftMaskInternal
{
internal static class AlwaysIncludedShadersProxy
{
private static GraphicsSettings s_GraphicsSettings;
private static SerializedProperty GetSerializedProperty()
{
if (!s_GraphicsSettings)
{
s_GraphicsSettings = typeof(GraphicsSettings).GetMethod("GetGraphicsSettings",
BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public)
?.Invoke(null, null) as GraphicsSettings;
}
return new SerializedObject(s_GraphicsSettings).FindProperty("m_AlwaysIncludedShaders");
}
public static IEnumerable<Shader> GetShaders()
{
var sp = GetSerializedProperty();
for (var i = 0; i < sp.arraySize; i++)
{
if (sp.GetArrayElementAtIndex(i).objectReferenceValue is Shader shader)
{
yield return shader;
}
}
}
public static void Remove(Shader shader)
{
var sp = GetSerializedProperty();
for (var i = 0; i < sp.arraySize; i++)
{
if (sp.GetArrayElementAtIndex(i).objectReferenceValue == shader)
{
sp.DeleteArrayElementAtIndex(i);
}
}
ShrinkArray(sp);
sp.serializedObject.ApplyModifiedProperties();
}
public static void Add(Shader shader)
{
var sp = GetSerializedProperty();
for (var i = 0; i < sp.arraySize; i++)
{
if (sp.GetArrayElementAtIndex(i).objectReferenceValue == shader)
{
return;
}
}
var index = sp.arraySize;
sp.InsertArrayElementAtIndex(index);
sp.GetArrayElementAtIndex(index).objectReferenceValue = shader;
ShrinkArray(sp);
sp.serializedObject.ApplyModifiedProperties();
}
private static void ShrinkArray(SerializedProperty sp)
{
var removed = 0;
for (var i = 0; i < sp.arraySize; i++)
{
if (!sp.GetArrayElementAtIndex(i).objectReferenceValue)
{
removed++;
}
else if (0 < removed)
{
sp.MoveArrayElement(i, i - removed);
}
}
sp.arraySize -= removed;
}
}
}
#endif