You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think it might be some internal glitch speaking of timing in VContainer, maybe someone already had this issue.
Let's say, we have RootContext(assigned in VContainer settings) and BootContext(on the BootScene) that loads another 2 scenes.
Scene1 has Scene1Context on it, and Scene2 respectively has Scene2Context on it.
Btw, by Context, sure I mean inherited from LifetimeScope.
So, if I trying to start two coroutines in IStartable.Start() of Boot(entry point of BootContext), then Parent of Scene1Context becomes RootContext and not BootContext.
But, if I either load those two scenes in one using block(with EnqueueParent of course) or just by pressing some input keys in arbitrary points of time - all is OK, and both Scene1Context and Scene2Context have BootContext as it's parent.
Examples of code:
Coroutines with loading scenes
private IEnumerator LoadScene1Async()
{
using (LifetimeScope.Enqueue(this.ServiceAInstaller))
{
using (LifetimeScope.EnqueueParent(this.Context))
{
var loading = SceneManager.LoadSceneAsync("Scene1", LoadSceneMode.Additive);
while (loading.isDone == false)
{
yield return null;
}
}
}
}
private IEnumerator LoadScene2Async()
{
using (LifetimeScope.Enqueue(this.ServiceAInstaller))
{
using (LifetimeScope.EnqueueParent(this.Context))
{
var loading = SceneManager.LoadSceneAsync("Scene2", LoadSceneMode.Additive);
while (loading.isDone == false)
{
yield return null;
}
}
}
}
Starting coroutines in Boot.Start(in which case Scene1Context's parent becomes RootContext and not a BootContext)
Loading scenes by input keys(works as predicted - every scene context has the same parent - BootContext)
public void Tick()
{
if (Input.GetKeyDown(KeyCode.Alpha1))
{
this.Context.StartCoroutine(this.LoadScene1Async());
}
if (Input.GetKeyDown(KeyCode.Alpha2))
{
this.Context.StartCoroutine(this.LoadScene2Async());
}
}
Or third way(in which it does work pretty good as well)
private IEnumerator LoadScenesAsync()
{
using (LifetimeScope.Enqueue(this.ServiceAInstaller))
{
using (LifetimeScope.EnqueueParent(this.Context))
{
var loading = SceneManager.LoadSceneAsync("Scene1", LoadSceneMode.Additive);
while (loading.isDone == false)
{
yield return null;
}
var loading2 = SceneManager.LoadSceneAsync("Scene2", LoadSceneMode.Additive);
while (loading2.isDone == false)
{
yield return null;
}
}
}
}
The text was updated successfully, but these errors were encountered:
I think it might be some internal glitch speaking of timing in VContainer, maybe someone already had this issue.
Let's say, we have RootContext(assigned in VContainer settings) and BootContext(on the BootScene) that loads another 2 scenes.
Scene1 has Scene1Context on it, and Scene2 respectively has Scene2Context on it.
Btw, by Context, sure I mean inherited from LifetimeScope.
So, if I trying to start two coroutines in IStartable.Start() of Boot(entry point of BootContext), then Parent of Scene1Context becomes RootContext and not BootContext.
But, if I either load those two scenes in one using block(with EnqueueParent of course) or just by pressing some input keys in arbitrary points of time - all is OK, and both Scene1Context and Scene2Context have BootContext as it's parent.
Examples of code:
Coroutines with loading scenes
Starting coroutines in Boot.Start(in which case Scene1Context's parent becomes RootContext and not a BootContext)
Loading scenes by input keys(works as predicted - every scene context has the same parent - BootContext)
Or third way(in which it does work pretty good as well)
The text was updated successfully, but these errors were encountered: