-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
If a Resolver is created and the first loop of resolveContinuously() is run before Resolve becomes true then the coroutine will not be run again.
It works in the Complex Outlet Inlet sample because the subscriber registers before the next while loop.
Any subscriber afterwards only benefit from using the resolver if Resolve remains true during the lifetime of the resolver. This limits the scalability of using Resolvers in a project.
The coroutine could be moved to run in the Update loop:
private void Update(){
if(!Resolve) return;
....
}
Or for the coroutine to be started/stopped on change in subscribers:
public class Resolver : MonoBehaviour
{
...
private Coroutine _resolveRoutine;
private StreamFound _onStreamFound;
public StreamFound OnStreamFound
{
get => _onStreamFound;
set
{
_onStreamFound = value;
if (_onStreamFound != null && _resolveRoutine == null)
{
_resolveRoutine = StartCoroutine(resolveContinuously());
}
}
}
private StreamLost _onStreamLost;
public StreamLost OnStreamLost
{
get => _onStreamLost;
set
{
_onStreamLost = value;
if (_onStreamFound != null && _resolveRoutine == null)
{
_resolveRoutine = StartCoroutine(resolveContinuously());
}
}
}
...
public void Start()
{
resolver = new ContinuousResolver(forgetStreamAfter);
_resolveRoutine = StartCoroutine(resolveContinuously());
}
...
private IEnumerator resolveContinuously()
{
while (Resolve)
{
...
}
yield return null;
_resolveRoutine = null;
}
}
}
Metadata
Metadata
Assignees
Labels
No labels