diff --git a/Assets/Editor/BuildScript.cs b/Assets/Editor/BuildScript.cs index 8b7a193a3..02cd333a1 100644 --- a/Assets/Editor/BuildScript.cs +++ b/Assets/Editor/BuildScript.cs @@ -225,7 +225,7 @@ namespace UnityBuilderAction { Directory.CreateDirectory(assetBundleDirectory); } - BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.ForceRebuildAssetBundle, buildTarget); + BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.ForceRebuildAssetBundle | BuildAssetBundleOptions.ChunkBasedCompression, buildTarget); BuildSummary buildSummary = BuildPipeline.BuildPlayer(buildPlayerOptions).summary; ReportSummary(buildSummary); diff --git a/Assets/Editor/CreateAssetBundles.cs b/Assets/Editor/CreateAssetBundles.cs index ab36d23cf..008089a3a 100644 --- a/Assets/Editor/CreateAssetBundles.cs +++ b/Assets/Editor/CreateAssetBundles.cs @@ -9,14 +9,47 @@ using UnityEngine; public class CreateAssetBundles { - [MenuItem("Assets/Build AssetBundles")] - static void BuildAllAssetBundles() + [MenuItem("Assets/Build AssetBundles/Current Platform")] + static void BuildAllAssetBundlesCurrPlatform() { - string assetBundleDirectory = "Assets/StreamingAssets"; - if (!Directory.Exists(Application.streamingAssetsPath)) - { - Directory.CreateDirectory(assetBundleDirectory); + string assetBundleDirectory = "Assets/StreamingAssets"; + if (!Directory.Exists(Application.streamingAssetsPath)) + { + Directory.CreateDirectory(assetBundleDirectory); + } + BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget); } - BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget); + + [MenuItem("Assets/Build AssetBundles/Windows")] + static void BuildAllAssetBundlesWindows() + { + string assetBundleDirectory = "Assets/StreamingAssets/Windows"; + if (!Directory.Exists(Application.streamingAssetsPath)) + { + Directory.CreateDirectory(assetBundleDirectory); + } + BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.StandaloneWindows); + } + + [MenuItem("Assets/Build AssetBundles/Linux")] + static void BuildAllAssetBundlesLinux() + { + string assetBundleDirectory = "Assets/StreamingAssets/Linux"; + if (!Directory.Exists(Application.streamingAssetsPath)) + { + Directory.CreateDirectory(assetBundleDirectory); + } + BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.StandaloneLinux64); + } + + [MenuItem("Assets/Build AssetBundles/Mac")] + static void BuildAllAssetBundlesMacOS() + { + string assetBundleDirectory = "Assets/StreamingAssets/Mac"; + if (!Directory.Exists(Application.streamingAssetsPath)) + { + Directory.CreateDirectory(assetBundleDirectory); + } + BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.StandaloneOSX); } } \ No newline at end of file diff --git a/Assets/Resources/Prefabs/GameView/Cursor.prefab b/Assets/Resources/Prefabs/GameView/Cursor.prefab index 1ffd930e5..f935ad816 100644 --- a/Assets/Resources/Prefabs/GameView/Cursor.prefab +++ b/Assets/Resources/Prefabs/GameView/Cursor.prefab @@ -123,7 +123,7 @@ MonoBehaviour: mouseMoveSpeed: 0 DSGuy: {fileID: 285182280031512481} DSGuyAnimator: {fileID: 4592128791974829295} - flickCoeff: 4 + flickCoeff: 12 flickInitMul: 64 InnerCircle: {fileID: 285182279842109877} Circle: {fileID: 285182279897966106} diff --git a/Assets/Scripts/CircleCursor.cs b/Assets/Scripts/CircleCursor.cs index 13ace2d5a..542de8cac 100644 --- a/Assets/Scripts/CircleCursor.cs +++ b/Assets/Scripts/CircleCursor.cs @@ -70,7 +70,6 @@ namespace HeavenStudio vel -= flickCoeff * Time.deltaTime * vel; flickDeltaPos += vel * Time.deltaTime; DSGuy.transform.position = flickStart + flickDeltaPos; - Debug.Log(vel.magnitude); } else { @@ -89,7 +88,6 @@ namespace HeavenStudio } else if (PlayerInput.GetIsAction(Minigame.InputAction_FlickRelease)) { - Debug.Log(deltaPos.magnitude * flickInitMul); Flick(pos, deltaPos * flickInitMul); } diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index f573b87e2..23994d741 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -364,8 +364,8 @@ namespace HeavenStudio if (inf != null && inf.usesAssetBundle && !inf.AssetsLoaded) { Debug.Log($"ASYNC loading assetbundles for game {gameName}"); - StartCoroutine(inf.LoadCommonAssetBundleAsync()); - StartCoroutine(inf.LoadLocalizedAssetBundleAsync()); + StartCoroutine(inf.LoadCommonAssetBundleAsync(this)); + StartCoroutine(inf.LoadLocalizedAssetBundleAsync(this)); } currentPreSwitch++; } @@ -390,8 +390,8 @@ namespace HeavenStudio if (inf != null && inf.usesAssetBundle && !inf.AssetsLoaded) { Debug.Log($"ASYNC loading assetbundles for game {gameName}"); - StartCoroutine(inf.LoadCommonAssetBundleAsync()); - StartCoroutine(inf.LoadLocalizedAssetBundleAsync()); + StartCoroutine(inf.LoadCommonAssetBundleAsync(this)); + StartCoroutine(inf.LoadLocalizedAssetBundleAsync(this)); } currentPreEvent++; } @@ -945,7 +945,7 @@ namespace HeavenStudio { var gameInfo = GetGameInfo(game); //load the games' sound sequences - // TODO: this blocks the main thread, and sound sequences sould be stored in a ScriptableObject + // TODO: sound sequences sould be stored in a ScriptableObject if (gameInfo != null && gameInfo.LoadedSoundSequences == null) gameInfo.LoadedSoundSequences = GetGame(game).GetComponent().SoundSequences; } @@ -970,8 +970,9 @@ namespace HeavenStudio if (gameInfo.usesAssetBundle) { //game is packed in an assetbundle, load from that instead - // this is fucked!! figure out a way to make this async if (gameInfo.LoadedPrefab != null) return gameInfo.LoadedPrefab; + // StartCoroutine(gameInfo.LoadCommonAudioClipsAsync()); + // StartCoroutine(gameInfo.LoadLocalizedAudioClipsAsync()); return gameInfo.GetCommonAssetBundle().LoadAsset(name); } name = gameInfo.LoadableName; diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index a1c797213..d8f8750fe 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -361,37 +361,29 @@ namespace HeavenStudio return bundleCommon; } - public IEnumerator LoadCommonAssetBundleAsync() + AssetBundleCreateRequest commonBundleRequest; + public IEnumerator LoadCommonAssetBundleAsync(MonoBehaviour runner) { if (commonPreloaded || commonLoaded) yield break; commonPreloaded = true; if (!usesAssetBundle) yield break; if (bundleCommon != null) yield break; - AssetBundleCreateRequest asyncBundleRequest = AssetBundle.LoadFromFileAsync(Path.Combine(Application.streamingAssetsPath, wantAssetBundle + "/common")); + if (commonBundleRequest == null) + commonBundleRequest = AssetBundle.LoadFromFileAsync(Path.Combine(Application.streamingAssetsPath, wantAssetBundle + "/common")); if (bundleCommon != null) yield break; - yield return asyncBundleRequest; + yield return commonBundleRequest; - bundleCommon = asyncBundleRequest.assetBundle; + bundleCommon = commonBundleRequest.assetBundle; commonLoaded = true; + commonBundleRequest = null; - //load game prefab - AssetBundleRequest prefabRequest = bundleCommon.LoadAssetAsync(name); - yield return prefabRequest; - loadedPrefab = prefabRequest.asset as GameObject; - - // preload audioclips - AssetBundleRequest audioRequest = bundleCommon.LoadAllAssetsAsync(); - yield return audioRequest; - - // load sound sequences here for now - if (loadedPrefab.TryGetComponent(out Games.Minigame minigame)) - { - soundSequences = minigame.SoundSequences; - } + runner.StartCoroutine(LoadGamePrefabAsync()); + // runner.StartCoroutine(LoadCommonAudioClipsAsync()); } - public IEnumerator LoadLocalizedAssetBundleAsync() + AssetBundleCreateRequest localeBundleRequest; + public IEnumerator LoadLocalizedAssetBundleAsync(MonoBehaviour runner) { if (localePreloaded) yield break; localePreloaded = true; @@ -399,17 +391,74 @@ namespace HeavenStudio if (!usesAssetBundle) yield break; if (localeLoaded && bundleLocalized != null && currentLoadedLocale == defaultLocale) yield break; - AssetBundleCreateRequest asyncBundleRequest = AssetBundle.LoadFromFileAsync(Path.Combine(Application.streamingAssetsPath, wantAssetBundle + "/locale." + defaultLocale)); + if (localeBundleRequest == null) + localeBundleRequest = AssetBundle.LoadFromFileAsync(Path.Combine(Application.streamingAssetsPath, wantAssetBundle + "/locale." + defaultLocale)); if (localeLoaded && bundleLocalized != null && currentLoadedLocale == defaultLocale) yield break; - yield return asyncBundleRequest; + yield return localeBundleRequest; - bundleLocalized = asyncBundleRequest.assetBundle; + bundleLocalized = localeBundleRequest.assetBundle; currentLoadedLocale = defaultLocale; localeLoaded = true; + localeBundleRequest = null; - // preload audioclips - AssetBundleRequest audioRequest = bundleLocalized.LoadAllAssetsAsync(); - yield return audioRequest; + // runner.StartCoroutine(LoadLocalizedAudioClipsAsync()); + } + + AssetBundleRequest prefabRequest; + public IEnumerator LoadGamePrefabAsync() + { + if (!usesAssetBundle) yield break; + if (!commonLoaded) yield break; + if (bundleCommon == null) yield break; + + if (prefabRequest == null) + { + prefabRequest = bundleCommon.LoadAssetAsync(name); + prefabRequest.priority = 0; + } + yield return prefabRequest; + loadedPrefab = prefabRequest.asset as GameObject; + prefabRequest = null; + + // load sound sequences here for now + // this is taxing and is still done synchronously + // move sequences to their own assets so that we don't have to look up a component + if (loadedPrefab.TryGetComponent(out Games.Minigame minigame)) + { + soundSequences = minigame.SoundSequences; + } + } + + AssetBundleRequest audioCommonRequest; + public IEnumerator LoadCommonAudioClipsAsync() + { + if (!usesAssetBundle) yield break; + if (!commonLoaded) yield break; + if (bundleCommon == null) yield break; + + if (audioCommonRequest == null) + { + audioCommonRequest = bundleCommon.LoadAllAssetsAsync(); + audioCommonRequest.priority = 1; + } + yield return audioCommonRequest; + audioCommonRequest = null; + } + + AssetBundleRequest audioLocaleRequest; + public IEnumerator LoadLocalizedAudioClipsAsync() + { + if (!usesAssetBundle) yield break; + if (!localeLoaded) yield break; + if (bundleLocalized == null) yield break; + + if (audioLocaleRequest == null) + { + audioLocaleRequest = bundleLocalized.LoadAllAssetsAsync(); + audioLocaleRequest.priority = 1; + } + yield return audioLocaleRequest; + audioLocaleRequest = null; } }