41 lines
945 B
C#
41 lines
945 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BITKit;
|
|
using BITKit.IO;
|
|
using BITKit.Mod;
|
|
using Cysharp.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using YooAsset;
|
|
|
|
namespace BITFALL.HotFix
|
|
{
|
|
public class FixShaderRuntime : MonoBehaviour
|
|
{
|
|
private void OnEnable()
|
|
{
|
|
YooAssetUtils.OnPackageRegistered += Execute;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
YooAssetUtils.OnPackageRegistered -= Execute;
|
|
}
|
|
|
|
private async void Execute(string obj)
|
|
{
|
|
var package = YooAssets.GetPackage(obj);
|
|
foreach (var asset in package.GetAssetInfos("material"))
|
|
{
|
|
var assetHandle = package.LoadAssetAsync<Material>(asset.AssetPath);
|
|
await assetHandle;
|
|
if (destroyCancellationToken.IsCancellationRequested) return;
|
|
if (assetHandle.AssetObject is not Material material) continue;
|
|
material.shader = Shader.Find(material.shader.name);
|
|
}
|
|
}
|
|
}
|
|
}
|