Unity-SerializeReferenceExtensions icon indicating copy to clipboard operation
Unity-SerializeReferenceExtensions copied to clipboard

[BUG] Playing while prefab selection with serializerefence is giving errors

Open D4rWiNSS opened this issue 1 month ago • 0 comments

What happened?

If you have an array like this:

[SerializeReference, SubclassSelector] ISkillEffect[] effects = Array.Empty<ISkillEffect>();

and you select a prefab that contains that line before clicking to play. When you click play you get the following errors:

UnityException: GetName can only be called from the main thread. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.

ArgumentException: An item with the same key has already been added. Key: 35651587

NullReferenceException: Object reference not set to an instance of an object UnityEngine.UIElements.UIR.MeshGenerator.DrawText (System.Collections.Generic.List1[T] vertices, System.Collections.Generic.List1[T] indices, System.Collections.Generic.List1[T] materials, System.Collections.Generic.List1[T] renderModes) (at <b2858548e25c4db4bad82249a9cb7b34>:0) UnityEngine.UIElements.UITKTextJobSystem.AddDrawEntries (UnityEngine.UIElements.MeshGenerationContext mgc, System.Object _) (at <b2858548e25c4db4bad82249a9cb7b34>:0) UnityEngine.UIElements.UIR.MeshGenerationDeferrer.Invoke (UnityEngine.UIElements.UIR.MeshGenerationDeferrer+CallbackInfo ci, UnityEngine.UIElements.MeshGenerationContext mgc) (at <b2858548e25c4db4bad82249a9cb7b34>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Package Version

1.6.1

Unity Version

Unity 6.0.58f2

D4rWiNSS avatar Nov 11 '25 12:11 D4rWiNSS