Skip to content

Commit

Permalink
Merge pull request #332 from JasonXuDeveloper/development
Browse files Browse the repository at this point in the history
fixed JPrefab bug
  • Loading branch information
JasonXuDeveloper authored May 23, 2022
2 parents 7d0ffe0 + ea3db7a commit c04dc66
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Binary file not shown.
Binary file not shown.
15 changes: 8 additions & 7 deletions UnityProject/HotUpdateScripts/JEngine/Core/JPrefab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ private JPrefab(string path, string package, bool async, Action<bool, JPrefab> c
}
if (async)
{
_ = LoadPrefabAsync(path, complete);
LoadPrefabAsync(path, package, complete).Coroutine();
}
else
{
var obj = AssetMgr.Load(path);
Instance = obj != null ? obj as GameObject : null;
var obj = AssetMgr.Load<GameObject>(path, package);
Instance = obj;
Loaded = true;
}
this.path = path;
Expand All @@ -95,17 +95,18 @@ private JPrefab(string path, string package, bool async, Action<bool, JPrefab> c
/// </summary>
public async Task WaitForAsyncLoading()
{
while(!Loaded)
await Task.Delay(1);
while (!Loaded && !Error)
{
await Task.Delay(1);
}
}


private async Task LoadPrefabAsync(string path, Action<bool, JPrefab> callback)
private async ET.ETTask LoadPrefabAsync(string path, string package, Action<bool, JPrefab> callback)
{
var obj = await AssetMgr.LoadAsync(path);
Instance = obj != null ? obj as GameObject : null;
var obj = await AssetMgr.LoadAsync<GameObject>(path, package);
Instance = obj;
Loaded = true;
callback?.Invoke(!Error, this);
}
Expand Down

0 comments on commit c04dc66

Please sign in to comment.