(hopefullyt) fix asset loading issue
This commit is contained in:
parent
10e9a5e35d
commit
64cbe48863
|
@ -171,7 +171,7 @@ namespace HeavenStudio
|
||||||
|
|
||||||
songPosBeat = GetBeatFromSongPos(time);
|
songPosBeat = GetBeatFromSongPos(time);
|
||||||
|
|
||||||
gameManager.SetCurrentEventToClosest(beat);
|
gameManager.SetCurrentEventToClosest(beat, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlaySetup(double beat)
|
public void PlaySetup(double beat)
|
||||||
|
|
|
@ -118,24 +118,22 @@ namespace HeavenStudio
|
||||||
|
|
||||||
public static List<RiqEntity> GetAllInGameManagerList(string gameName, string[] include)
|
public static List<RiqEntity> GetAllInGameManagerList(string gameName, string[] include)
|
||||||
{
|
{
|
||||||
List<RiqEntity> temp1 = instance.gameManager.Beatmap.Entities.FindAll(c => c.datamodel.Split('/')[0] == gameName);
|
Predicate<RiqEntity> match = c =>
|
||||||
List<RiqEntity> temp2 = new List<RiqEntity>();
|
|
||||||
foreach (string s in include)
|
|
||||||
{
|
{
|
||||||
temp2.AddRange(temp1.FindAll(c => c.datamodel.Split('/')[1].Equals(s)));
|
string[] details = c.datamodel.Split('/');
|
||||||
}
|
return details[0] == gameName && include.Contains(details[1]);
|
||||||
return temp2;
|
};
|
||||||
|
return instance.gameManager.Beatmap.Entities.FindAll(match);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<RiqEntity> GetAllInGameManagerListExclude(string gameName, string[] exclude)
|
public static List<RiqEntity> GetAllInGameManagerListExclude(string gameName, string[] exclude)
|
||||||
{
|
{
|
||||||
List<RiqEntity> temp1 = instance.gameManager.Beatmap.Entities.FindAll(c => c.datamodel.Split('/')[0] == gameName);
|
Predicate<RiqEntity> match = c =>
|
||||||
List<RiqEntity> temp2 = new List<RiqEntity>();
|
|
||||||
foreach (string s in exclude)
|
|
||||||
{
|
{
|
||||||
temp2.AddRange(temp1.FindAll(c => !c.datamodel.Split('/')[1].Equals(s)));
|
string[] details = c.datamodel.Split('/');
|
||||||
}
|
return details[0] == gameName && !exclude.Contains(details[1]);
|
||||||
return temp2;
|
};
|
||||||
|
return instance.gameManager.Beatmap.Entities.FindAll(match);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Minigames.Minigame> FXOnlyGames()
|
public static List<Minigames.Minigame> FXOnlyGames()
|
||||||
|
|
|
@ -22,7 +22,6 @@ namespace HeavenStudio
|
||||||
|
|
||||||
[Header("Lists")]
|
[Header("Lists")]
|
||||||
[NonSerialized] public RiqBeatmap Beatmap = new();
|
[NonSerialized] public RiqBeatmap Beatmap = new();
|
||||||
private Dictionary<string, GameObject> cachedGamePrefabs = new();
|
|
||||||
[NonSerialized] public ObjectPool<Sound> SoundObjects;
|
[NonSerialized] public ObjectPool<Sound> SoundObjects;
|
||||||
|
|
||||||
[Header("Components")]
|
[Header("Components")]
|
||||||
|
@ -1124,7 +1123,7 @@ namespace HeavenStudio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (beat + 0.25 > Math.Max(conductor.songPositionInBeatsAsDouble, 0))
|
while (conductor.GetUnSwungBeat(beat + 0.25) > Math.Max(conductor.unswungSongPositionInBeatsAsDouble, 0))
|
||||||
{
|
{
|
||||||
if (!conductor.isPlaying)
|
if (!conductor.isPlaying)
|
||||||
{
|
{
|
||||||
|
@ -1165,13 +1164,18 @@ namespace HeavenStudio
|
||||||
|
|
||||||
public void DestroyGame()
|
public void DestroyGame()
|
||||||
{
|
{
|
||||||
cachedGamePrefabs.Clear();
|
|
||||||
SoundByte.UnloadAudioClips();
|
SoundByte.UnloadAudioClips();
|
||||||
SetGame("noGame");
|
SetGame("noGame");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string currentGameRequest = null;
|
||||||
private IEnumerator WaitAndSetGame(string game, bool useMinigameColor = true)
|
private IEnumerator WaitAndSetGame(string game, bool useMinigameColor = true)
|
||||||
{
|
{
|
||||||
|
if (game == currentGameRequest)
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
currentGameRequest = game;
|
||||||
var inf = GetGameInfo(game);
|
var inf = GetGameInfo(game);
|
||||||
if (inf != null && inf.usesAssetBundle)
|
if (inf != null && inf.usesAssetBundle)
|
||||||
{
|
{
|
||||||
|
@ -1179,13 +1183,15 @@ namespace HeavenStudio
|
||||||
{
|
{
|
||||||
// Debug.Log($"ASYNC loading assetbundles for game {game}");
|
// Debug.Log($"ASYNC loading assetbundles for game {game}");
|
||||||
inf.LoadAssetsAsync().Forget();
|
inf.LoadAssetsAsync().Forget();
|
||||||
|
yield return new WaitUntil(() => inf.AssetsLoaded);
|
||||||
}
|
}
|
||||||
yield return new WaitUntil(() => inf.AssetsLoaded);
|
|
||||||
SetGame(game, useMinigameColor);
|
SetGame(game, useMinigameColor);
|
||||||
|
currentGameRequest = null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetGame(game, useMinigameColor);
|
SetGame(game, useMinigameColor);
|
||||||
|
currentGameRequest = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1200,10 +1206,14 @@ namespace HeavenStudio
|
||||||
|
|
||||||
public GameObject GetGame(string name)
|
public GameObject GetGame(string name)
|
||||||
{
|
{
|
||||||
var gameInfo = GetGameInfo(name);
|
if (name is null or "" or "noGame")
|
||||||
|
{
|
||||||
|
return Resources.Load<GameObject>($"Games/noGame");
|
||||||
|
}
|
||||||
|
|
||||||
|
Minigames.Minigame gameInfo = GetGameInfo(name);
|
||||||
if (gameInfo != null)
|
if (gameInfo != null)
|
||||||
{
|
{
|
||||||
GameObject prefab;
|
|
||||||
if (gameInfo.inferred)
|
if (gameInfo.inferred)
|
||||||
{
|
{
|
||||||
return Resources.Load<GameObject>($"Games/noGame");
|
return Resources.Load<GameObject>($"Games/noGame");
|
||||||
|
@ -1226,6 +1236,8 @@ namespace HeavenStudio
|
||||||
return Resources.Load<GameObject>($"Games/noGame");
|
return Resources.Load<GameObject>($"Games/noGame");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameObject prefab;
|
||||||
if (gameInfo.usesAssetBundle)
|
if (gameInfo.usesAssetBundle)
|
||||||
{
|
{
|
||||||
//game is packed in an assetbundle, load from that instead
|
//game is packed in an assetbundle, load from that instead
|
||||||
|
@ -1234,6 +1246,11 @@ namespace HeavenStudio
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"Game prefab wasn't cached, loading from assetbundle for game {name}");
|
Debug.LogWarning($"Game prefab wasn't cached, loading from assetbundle for game {name}");
|
||||||
|
if (gameInfo.LoadingPrefab)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"Game {name} is already loading, using noGame");
|
||||||
|
return Resources.Load<GameObject>($"Games/noGame");
|
||||||
|
}
|
||||||
return gameInfo.LoadGamePrefab();
|
return gameInfo.LoadGamePrefab();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -1251,6 +1268,7 @@ namespace HeavenStudio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// games with no assetbundle (usually indev games)
|
||||||
prefab = Resources.Load<GameObject>($"Games/{name}");
|
prefab = Resources.Load<GameObject>($"Games/{name}");
|
||||||
if (prefab != null)
|
if (prefab != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -395,8 +395,10 @@ namespace HeavenStudio
|
||||||
|
|
||||||
public bool usesAssetBundle => wantAssetBundle is not null or "";
|
public bool usesAssetBundle => wantAssetBundle is not null or "";
|
||||||
public bool hasLocales => supportedLocales.Count > 0;
|
public bool hasLocales => supportedLocales.Count > 0;
|
||||||
public bool AssetsLoaded => ((hasLocales && localeLoaded && currentLoadedLocale == defaultLocale) || (!hasLocales)) && commonLoaded && loadComplete;
|
public bool AssetsLoaded => ((hasLocales && localeLoaded && currentLoadedLocale == defaultLocale) || (!hasLocales)) && commonLoaded && (!loadingPrefab) && loadComplete;
|
||||||
public bool AlreadyLoading => alreadyLoading;
|
public bool AlreadyLoading => alreadyLoading;
|
||||||
|
public bool LoadingPrefab => loadingPrefab;
|
||||||
|
|
||||||
public bool SequencesPreloaded => soundSequences != null;
|
public bool SequencesPreloaded => soundSequences != null;
|
||||||
public string LoadableName => inferred ? "noGame" : name;
|
public string LoadableName => inferred ? "noGame" : name;
|
||||||
public GameObject LoadedPrefab => loadedPrefab;
|
public GameObject LoadedPrefab => loadedPrefab;
|
||||||
|
@ -410,6 +412,7 @@ namespace HeavenStudio
|
||||||
private bool localePreloaded = false;
|
private bool localePreloaded = false;
|
||||||
private GameObject loadedPrefab = null;
|
private GameObject loadedPrefab = null;
|
||||||
|
|
||||||
|
bool loadingPrefab = false;
|
||||||
bool loadComplete = false;
|
bool loadComplete = false;
|
||||||
|
|
||||||
private SoundSequence.SequenceKeyValue[] soundSequences = null;
|
private SoundSequence.SequenceKeyValue[] soundSequences = null;
|
||||||
|
@ -510,6 +513,7 @@ namespace HeavenStudio
|
||||||
if (alreadyLoading || AssetsLoaded || !usesAssetBundle) return;
|
if (alreadyLoading || AssetsLoaded || !usesAssetBundle) return;
|
||||||
loadComplete = false;
|
loadComplete = false;
|
||||||
alreadyLoading = true;
|
alreadyLoading = true;
|
||||||
|
loadingPrefab = true;
|
||||||
await UniTask.WhenAll(LoadCommonAssetBundleAsync(), LoadLocalizedAssetBundleAsync());
|
await UniTask.WhenAll(LoadCommonAssetBundleAsync(), LoadLocalizedAssetBundleAsync());
|
||||||
await UniTask.WhenAll(LoadGamePrefabAsync(), LoadCommonAudioClips(), LoadLocalizedAudioClips());
|
await UniTask.WhenAll(LoadGamePrefabAsync(), LoadCommonAudioClips(), LoadLocalizedAudioClips());
|
||||||
SoundByte.PreloadGameAudioClips(this);
|
SoundByte.PreloadGameAudioClips(this);
|
||||||
|
@ -585,6 +589,7 @@ namespace HeavenStudio
|
||||||
soundSequences = minigame.SoundSequences;
|
soundSequences = minigame.SoundSequences;
|
||||||
}
|
}
|
||||||
loadedPrefab = prefab;
|
loadedPrefab = prefab;
|
||||||
|
loadingPrefab = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameObject LoadGamePrefab()
|
public GameObject LoadGamePrefab()
|
||||||
|
@ -636,6 +641,7 @@ namespace HeavenStudio
|
||||||
}
|
}
|
||||||
SoundByte.UnloadAudioClips(name);
|
SoundByte.UnloadAudioClips(name);
|
||||||
loadComplete = false;
|
loadComplete = false;
|
||||||
|
loadingPrefab = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue