Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefab Requests are returned early #521

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Nautilus/Assets/ModPrefabRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal class ModPrefabRequest: IPrefabRequest

private readonly PrefabInfo prefabInfo;

private CoroutineTask<GameObject> task;
private IEnumerator task;

private TaskResult<GameObject> taskResult;

Expand All @@ -37,7 +37,7 @@ private void Init()
return;
}

task = new CoroutineTask<GameObject>(PrefabHandler.GetPrefabAsync(taskResult, prefabInfo, factory), taskResult);
task = PrefabHandler.GetPrefabAsync(taskResult, prefabInfo, factory);
}

public object Current
Expand Down Expand Up @@ -66,14 +66,12 @@ public bool MoveNext()

public void Reset()
{
Init();
task.Reset();
Done = false;
}

public void Release()
{
ModPrefabCache.RemovePrefabFromCache(prefabInfo.ClassID);
taskResult = null;
task = null;
Done = false;
Expand Down
6 changes: 6 additions & 0 deletions Nautilus/Handlers/PrefabHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ internal static IEnumerator GetPrefabAsync(TaskResult<GameObject> gameObject, Pr

private static IEnumerator InitPrefabAsync(TaskResult<GameObject> gameObject, PrefabInfo info, PrefabFactoryAsync prefabFactory)
{
if (prefabFactory == null)
{
InternalLogger.Error($"PrefabHandler: Prefab Factory for {info.ClassID} is null!");
yield break;
}

yield return prefabFactory(gameObject);

var obj = gameObject.Get();
Expand Down