From 70045b448f87e36dc3f3f4fdec8afce9243ccd07 Mon Sep 17 00:00:00 2001 From: Nazfib Date: Thu, 7 Nov 2024 02:06:31 +0100 Subject: [PATCH] Fix shader loading on Linux Fixes two issues: - Load the Linux shader assetbundle instead of the OSX version on Linux - The new assetbundle from #24 contain files other than the shaders - both intended (the new .cginc files), and a few unintended ones (in a folder named b9, there are .obj and .mat files). For the former, fix the exception that occured when trying to load those files as shaders. For the latter, the assetbundles should be recompiled without those files. --- src/Utilities/KKGraphics.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Utilities/KKGraphics.cs b/src/Utilities/KKGraphics.cs index 106dd4e5..1f351315 100644 --- a/src/Utilities/KKGraphics.cs +++ b/src/Utilities/KKGraphics.cs @@ -67,7 +67,7 @@ internal static void LoadShaderBundles () bundleFileName = "kkshaders.osx"; break; case RuntimePlatform.LinuxPlayer: - bundleFileName = "kkshaders.osx"; + bundleFileName = "kkshaders.linux"; break; default: bundleFileName = "kkshaders.windows"; @@ -106,8 +106,10 @@ internal static void LoadShaderBundles () private static void LoadAndRegisterShader(AssetBundle bundle , string shaderName) { Shader newShader = bundle.LoadAsset(shaderName); + if (newShader == null) { return; } // This file is not a shader; ignore it. + GameObject.DontDestroyOnLoad(newShader); - if (newShader == null || !newShader.isSupported) + if (!newShader.isSupported) { Log.Error("could not load shader: " + shaderName + " from: " + bundle.name); }