public static void UpdateEventTubeLightList() { LightSwitchEventEffect[] lightSwitchEvents = Resources.FindObjectsOfTypeAll <LightSwitchEventEffect>(); foreach (LightSwitchEventEffect switchEffect in lightSwitchEvents) { ReflectionUtil.SetPrivateField( switchEffect, "_lights", BloomPrePass.GetLightsWithID(ReflectionUtil.GetPrivateField <int>(switchEffect, "_lightsID")) ); } }
/// <summary> /// Asynchronously loads a <see cref="CustomPlatform"/> from a specified file path /// </summary> private async Task <CustomPlatform?> LoadPlatformFromFileAsyncCore(string fullPath) { byte[] bundleData = await Task.Run(() => File.ReadAllBytes(fullPath)); AssetBundle?assetBundle = await LoadAssetBundleFromBytesAsync(bundleData); if (assetBundle is null) { _siraLog.Error($"File could not be loaded:\n{fullPath}"); return(null); } GameObject?platformPrefab = await LoadAssetFromAssetBundleAsync <GameObject>(assetBundle, "_CustomPlatform"); if (platformPrefab is null) { assetBundle.Unload(true); _siraLog.Error($"Platform GameObject could not be loaded:\n{fullPath}"); return(null); } assetBundle.Unload(false); CustomPlatform?customPlatform = platformPrefab.GetComponent <CustomPlatform>(); if (customPlatform is null) { // Check for old platform global::CustomPlatform?legacyPlatform = platformPrefab.GetComponent <global::CustomPlatform>(); if (legacyPlatform is not null) { // Replace legacy platform component with up to date one customPlatform = platformPrefab.AddComponent <CustomPlatform>(); customPlatform.platName = legacyPlatform.platName; customPlatform.platAuthor = legacyPlatform.platAuthor; customPlatform.hideDefaultPlatform = true; // Remove old platform data UnityEngine.Object.Destroy(legacyPlatform); } else { // No CustomPlatform component, abort UnityEngine.Object.Destroy(platformPrefab); _siraLog.Error($"AssetBundle does not contain a CustomPlatform:\n{fullPath}"); return(null); } } Camera[] cameras = platformPrefab.GetComponentsInChildren <Camera>(true); foreach (Camera camera in cameras) { BloomPrePass bloomPrePass = camera.gameObject.AddComponent <BloomPrePass>(); _bloomPrepassRendererAccessor(ref bloomPrePass) = _bloomPrepassRenderer; _bloomPrePassEffectContainerAccessor(ref bloomPrePass) = _bloomPrePassEffectContainer; } customPlatform.platHash = await Task.Run(() => ComputeHash(bundleData)); customPlatform.fullPath = fullPath; customPlatform.name = $"{customPlatform.platName} by {customPlatform.platAuthor}"; return(customPlatform); }