Hi !
I’m facing a strange issue that gives me a big headache.
I have this foreach on a system :
foreach (var (animatorRef, entity) in
SystemAPI.Query<MonsterAnimatorRef>()
.WithNone<Monster, Dying>()
.WithEntityAccess())
{
animatorRef.Value.SetBool("Dying", true);
ecb.AddComponent<Dying>(entity);
}
Monster and Dying are two Tag Components.
MonsterAnimatorRef is a CleanupComponent :
public class MonsterAnimatorRef : ICleanupComponentData
{
public Animator Value;
}
Nothing crazy at first, it works well on Play Mode and on PC build.
On Android, when I kill a Monster (and therefore create an entity matching the query), the app crashes and logs this :
#00 Unity.Entities.ArchetypeChunk:get_Count () <.\Library\PackageCache\com.unity.entities@1.0.16\Unity.Entities\Iterators\ArchetypeChunkArray.cs:29>
#01 Unity.Entities.Internal.InternalEntityQueryEnumerator:MoveNextEntityRange (bool&,Unity.Entities.ArchetypeChunk&,int&,int&) <.\Library\PackageCache\com.unity.entities@1.0.16\Unity.Entities\Internal\InternalEntityQueryEnumerator.cs:166>
#02 MonsterDeathAnimateSystem/IFE_374884274_0/Enumerator:MoveNext () <C:\Users\Michael\jv\proto\arbalete\Unity.Entities.SourceGen.SystemGenerator\Unity.Entities.SourceGen.SystemGenerator.SystemGenerator\Temp\GeneratedCode\Assembly-CSharp\MonsterAnimateSystem__System_15642690750.g.cs:398>
#03 MonsterDeathAnimateSystem:OnUpdate (Unity.Entities.SystemState&) <C:\Users\Michael\jv\proto\arbalete\Assets\Game\Monsters\MonsterAnimateSystem.cs:50>
#04 MonsterDeathAnimateSystem:codegen__OnUpdate (intptr,intptr) <0x73>
#05 Unity.Entities.SystemBaseRegistry/<>c__DisplayClass9_0:b__0 (intptr,intptr) <.\Library\PackageCache\com.unity.entities@1.0.16\Unity.Entities\SystemBaseRegistry.cs:256>
#06 (wrapper native-to-managed) Unity.Entities.SystemBaseRegistry/<>c__DisplayClass9_0:b__0 (intptr,intptr)
#07 (wrapper managed-to-native) Unity.Entities.WorldUnmanagedImpl/Unity.Entities.UnmanagedUpdate_00001533$BurstDirectCall:wrapper_native_indirect_0xa3a0dfb8 (intptr&,void*)
#08 Unity.Entities.WorldUnmanagedImpl/Unity.Entities.UnmanagedUpdate_00001533$BurstDirectCall:Invoke (void*) <0x83>
#09 Unity.Entities.WorldUnmanagedImpl:UnmanagedUpdate (void*) <.\Library\PackageCache\com.unity.entities@1.0.16\Unity.Entities\WorldUnmanaged.cs:828>
#10 Unity.Entities.WorldUnmanagedImpl:UpdateSystem (Unity.Entities.SystemHandle) <.\Library\PackageCache\com.unity.entities@1.0.16\Unity.Entities\WorldUnmanaged.cs:894>
#11 Unity.Entities.ComponentSystemGroup:UpdateAllSystems () <.\Library\PackageCache\com.unity.entities@1.0.16\Unity.Entities\ComponentSystemGroup.cs:733>
#12 Unity.Entities.ComponentSystemGroup:OnUpdate () <.\Library\PackageCache\com.unity.entities@1.0.16\Unity.Entities\ComponentSystemGroup.cs:697>
#13 Unity.Entities.SystemBase:Update () <.\Library\PackageCache\com.unity.entities@1.0.16\Unity.Entities\SystemBase.cs:418>
#14 Unity.Entities.ScriptBehaviourUpdateOrder/DummyDelegateWrapper:TriggerUpdate () <.\Library\PackageCache\com.unity.entities@1.0.16\Unity.Entities\ScriptBehaviourUpdateOrder.cs:526>
#15 (wrapper runtime-invoke) object:runtime_invoke_void__this (object,intptr,intptr,intptr)
Line #03 is refering to “MonsterAnimateSystem.cs:50” : it corresponds to the closing curly bracket of the suspicious foreach (line 8 on my copy/paste).
The program can not enter the foreach.
It crashes before, while iterating on Entities (see lines #00 and #01).
Do you have any idea why this is happening ? Or how I could debug this ?
If you need any additional information please ask me.
Thank you.
(Using Unity 2022.3.14f1 and Entities 1.0.16)