Skip to content

Commit c04dc66

Browse files
Merge pull request #332 from JasonXuDeveloper/development
fixed JPrefab bug
2 parents 7d0ffe0 + ea3db7a commit c04dc66

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed
Binary file not shown.
Binary file not shown.

UnityProject/HotUpdateScripts/JEngine/Core/JPrefab.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ private JPrefab(string path, string package, bool async, Action<bool, JPrefab> c
7878
}
7979
if (async)
8080
{
81-
_ = LoadPrefabAsync(path, complete);
81+
LoadPrefabAsync(path, package, complete).Coroutine();
8282
}
8383
else
8484
{
85-
var obj = AssetMgr.Load(path);
86-
Instance = obj != null ? obj as GameObject : null;
85+
var obj = AssetMgr.Load<GameObject>(path, package);
86+
Instance = obj;
8787
Loaded = true;
8888
}
8989
this.path = path;
@@ -95,17 +95,18 @@ private JPrefab(string path, string package, bool async, Action<bool, JPrefab> c
9595
/// </summary>
9696
public async Task WaitForAsyncLoading()
9797
{
98-
while(!Loaded)
98+
await Task.Delay(1);
99+
while (!Loaded && !Error)
99100
{
100101
await Task.Delay(1);
101102
}
102103
}
103104

104105

105-
private async Task LoadPrefabAsync(string path, Action<bool, JPrefab> callback)
106+
private async ET.ETTask LoadPrefabAsync(string path, string package, Action<bool, JPrefab> callback)
106107
{
107-
var obj = await AssetMgr.LoadAsync(path);
108-
Instance = obj != null ? obj as GameObject : null;
108+
var obj = await AssetMgr.LoadAsync<GameObject>(path, package);
109+
Instance = obj;
109110
Loaded = true;
110111
callback?.Invoke(!Error, this);
111112
}

0 commit comments

Comments
 (0)