示例#1
0
        static AssetBundleDatabase()
        {
            string version = $"{VersionControl.CurrentMajor}.{VersionControl.CurrentMinor}";

            if (bundleBuildVersionManifest.TryGetValue(version, out string currentVersion))
            {
                if (currentVersion != Application.unityVersion)
                {
                    Log.Warning($"{VehicleHarmony.LogLabel} Unity Version {Application.unityVersion} does not match registered version for AssetBundles being loaded. You may encounter problems.");
                }
            }
            string        folderChecking = "default";
            List <string> loadFolders    = FilePaths.LoadFolderLocalFilePath(VehicleMod.settings.Mod.Content);

            try
            {
                foreach (string folder in loadFolders)
                {
                    string versionFilePath = Path.Combine(VehicleMod.settings.Mod.Content.RootDir, folder, ShaderAssetBundlePath);
                    folderChecking = versionFilePath;
                    if (File.Exists(versionFilePath))
                    {
                        ShaderBundle = AssetBundle.LoadFromFile(versionFilePath);
                        if (ShaderBundle is null)
                        {
                            throw new NullReferenceException();
                        }

                        CutoutComplexRGB     = LoadAssetBundleShader("Assets/Shaders/ShaderRGB.shader");
                        CutoutComplexPattern = LoadAssetBundleShader("Assets/Shaders/ShaderRGBPattern.shader");
                    }
                    goto CursorLoading;
                }
                throw new IOException();
            }
            catch (Exception ex)
            {
                SmashLog.Error($"Unable to load AssetBundle at <text>{folderChecking}</text>\nException = {ex.Message}");
            }
            CursorLoading :;
            try
            {
                foreach (string folder in loadFolders)
                {
                    string versionFilePath = Path.Combine(VehicleMod.settings.Mod.Content.RootDir, folder, CursorAssetBundlePath);
                    folderChecking = versionFilePath;
                    if (File.Exists(versionFilePath))
                    {
                        CursorBundle = AssetBundle.LoadFromFile(versionFilePath);
                        if (CursorBundle is null)
                        {
                            throw new NullReferenceException();
                        }

                        MouseHandOpen   = LoadAssetBundleTexture("Assets/Textures/MouseHandOpen.png");
                        MouseHandClosed = LoadAssetBundleTexture("Assets/Textures/MouseHandClosed.png");
                    }
                }
            }
            catch (Exception ex)
            {
                SmashLog.Error($"Unable to load AssetBundle at <text>{CursorAssetBundlePath}</text>\nException = {ex.Message}");
            }
        }