improve look of cursor
make assetbundles use chunk-based compression refactor assetbundle loading methods a bit
This commit is contained in:
parent
9a6f89ee77
commit
875c1ee66c
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Minigame>().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<GameObject>(name);
|
||||
}
|
||||
name = gameInfo.LoadableName;
|
||||
|
|
|
|||
|
|
@ -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<GameObject>(name);
|
||||
yield return prefabRequest;
|
||||
loadedPrefab = prefabRequest.asset as GameObject;
|
||||
|
||||
// preload audioclips
|
||||
AssetBundleRequest audioRequest = bundleCommon.LoadAllAssetsAsync<AudioClip>();
|
||||
yield return audioRequest;
|
||||
|
||||
// load sound sequences here for now
|
||||
if (loadedPrefab.TryGetComponent<Games.Minigame>(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<AudioClip>();
|
||||
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<GameObject>(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<Games.Minigame>(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<AudioClip>();
|
||||
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<AudioClip>();
|
||||
audioLocaleRequest.priority = 1;
|
||||
}
|
||||
yield return audioLocaleRequest;
|
||||
audioLocaleRequest = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue