Search Unity

Question NON ECS, Collections Package with Unity 2021.2 has now started throwing runtime errors

Discussion in 'Entity Component System' started by jGate99, Sep 20, 2021.

  1. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Hi there,

    I wrote a Non-ECS, Job System with Collections only code which worked fine until I upgraded both Unity 2021.2 and most recent Collections Package.
    Now i see errors like this

    UnityException: EditorPrefsGetInt is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead.

    This never happend before, so i sort of know how to solve this :( with lots of changes
    but when this change happened and why?

    Code (CSharp):
    1. Unity.Collections.NativeLeakDetection.Initialize () (at <4dc2257427d341fb9842705f290f2b68>:0)
    2. Unity.Collections.NativeLeakDetection.get_Mode () (at <4dc2257427d341fb9842705f290f2b68>:0)
    3. Unity.Collections.LowLevel.Unsafe.DisposeSentinel.CreateInternal (Unity.Collections.LowLevel.Unsafe.DisposeSentinel& sentinel, System.Int32 callSiteStackDepth) (at <4dc2257427d341fb9842705f290f2b68>:0)
    4. Unity.Collections.LowLevel.Unsafe.DisposeSentinel.Create (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle& safety, Unity.Collections.LowLevel.Unsafe.DisposeSentinel& sentinel, System.Int32 callSiteStackDepth, Unity.Collections.Allocator allocator) (at <4dc2257427d341fb9842705f290f2b68>:0)
    5. Unity.Collections.NativeList`1[T].Initialize[U] (System.Int32 initialCapacity, U& allocator, System.Int32 disposeSentinelStackDepth) (at Library/PackageCache/com.unity.collections@1.0.0-pre.5/Unity.Collections/NativeList.cs:141)
    6. Unity.Collections.NativeList`1[T]..ctor (System.Int32 initialCapacity, Unity.Collections.AllocatorManager+AllocatorHandle allocator, System.Int32 disposeSentinelStackDepth) (at Library/PackageCache/com.unity.collections@1.0.0-pre.5/Unity.Collections/NativeList.cs:176)
    7. Unity.Collections.NativeList`1[T]..ctor (System.Int32 initialCapacity, Unity.Collections.AllocatorManager+AllocatorHandle allocator) (at Library/PackageCache/com.unity.collections@1.0.0-pre.5/Unity.Collections/NativeList.cs:120)
    8. (at
    Regards