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
{{ message }}
This repository has been archived by the owner on Aug 22, 2018. It is now read-only.
Hello, it looks like Priority property doesn't work for AsyncScript. In my prototype I have two async scripts, one with priority -1 and one with 0. In this case I expects that async script with priority -1 will be executed before that one with priority 0, but it doesn't.
It's possible to easily reproduce this bug by:
create first async script, e.g.:
` public class TestScript1 : AsyncScript
{
public bool IsInitialized { get; private set; }
public override async Task Execute()
{
this.IsInitialized = true;
while (this.Game.IsRunning)
{
await Task.Delay(5000);
await this.Script.NextFrame();
}
}
}`
create second async script, e.g.:
`public class TestScript2 : AsyncScript
{
public bool IsInitialized { get; private set; }
public override async Task Execute()
{
this.IsInitialized = true;
var firstScript = this.Entity.Get<TestScript1>();
if (!firstScript.IsInitialized && firstScript.Priority == -1 && this.Priority == 0)
{
throw new InvalidOperationException("First script isn't initialized.");
}
while (this.Game.IsRunning)
{
await Task.Delay(5000);
await this.Script.NextFrame();
}
}
}`
attach both scripts to an entity (order probably doesn't matter, but to be safe, first TestScript2, then TestScript1)
set priority -1 for TestScript1 and 0 for TestScript2
run game and see "First script isn't initialized." exception
In documentation there is "Priorities apply to all kinds of scripts. This means that, for example, synchronous and asynchronous scripts don't have separate priority lists. They both join the same queue." so to me this definitely looks like a bug.
The text was updated successfully, but these errors were encountered:
Does it have the same behavior if you await once at the beginning of each script: await Script.NextFrame().
Maybe the priority is only taken into account when the script get scheduled for the next frame, which is still a bug but at least that would be a workaround.
Hello, it looks like Priority property doesn't work for AsyncScript. In my prototype I have two async scripts, one with priority -1 and one with 0. In this case I expects that async script with priority -1 will be executed before that one with priority 0, but it doesn't.
It's possible to easily reproduce this bug by:
create first async script, e.g.:
` public class TestScript1 : AsyncScript
{
public bool IsInitialized { get; private set; }
}`
create second async script, e.g.:
`public class TestScript2 : AsyncScript
{
public bool IsInitialized { get; private set; }
}`
attach both scripts to an entity (order probably doesn't matter, but to be safe, first TestScript2, then TestScript1)
set priority -1 for TestScript1 and 0 for TestScript2
run game and see "First script isn't initialized." exception
In documentation there is "Priorities apply to all kinds of scripts. This means that, for example, synchronous and asynchronous scripts don't have separate priority lists. They both join the same queue." so to me this definitely looks like a bug.
The text was updated successfully, but these errors were encountered: