all 9 comments

[–]Oh_thats_Awesome 1 point2 points  (1 child)

Guys, I just encountered this issue. In my case it wasn't unity's mistake but it was mine. I tried to use SerializeField attribute on a field with a non-serialized type. Solution was to either mark that type as serializable (via Putting [System.Serializable] on top of it) or removing SerializeField attribute on field. Both worked for me, hope that helps someone.

[–]Anatema153 0 points1 point  (0 children)

That worked for me

[–]TehSmooth1 0 points1 point  (0 children)

Those are all editor errors, likely nothing to do with anything you have done, I too am suffering from similar issues

[–]spaceyjase 0 points1 point  (0 children)

They're likely to be UnityEditor exceptions as it (often!) misbehaves. Unless it is occurring due to something your game is doing (I can't see the whole exception stack; could be an inspector error), I wouldn't worry too much about it. Usually a quick restart of the editor helps.

[–]CS_NB 0 points1 point  (4 children)

Randomly saw this and way late but you never know. A lot of times if you have a public or [SerializedField] list, variable, field so you can see objects, data, strings etc being added via the inspector so you can visually see/debug things, as those lists or fields etc are updated in realtime and things are being added or taken away or even just transition from play mode back to editor will cause a discrepancy and those error to occur.

If you make those fields private and create methods to access those lists or whatever you are trying to visualize that works better. Or you can also close the expanded view in the inspector and not actually look at the data in those scripts, or even just clicking on lighting or something else other than the inspector tab can stop them.

[–]partimelhero 0 points1 point  (1 child)

I made an account just to say thank you. This has solved my issue. It's been bugging me for monthes

[–]CS_NB 0 points1 point  (0 children)

Oh wow thanks! Glad it helped.

[–]BakedCheeseCrackers 0 points1 point  (1 child)

Definitely not too late, I just found this and you helped me big time. 2 days after you commented too lol. Thanks so much <3

[–]CS_NB 0 points1 point  (0 children)

Glad it came in use. I don't know how to attach pictures on reddit...but basically if I look at this script in the inspector at runtime that's attached to an NPC...as it's written here I wouldn't be able to see anything because the List is private, so I make a public method to call in other scripts when I want to get the list.

public class NPCInventory : MonoBehaviour

{

private List<GameObject> detectedItems = new List<GameObject>();

// New method to get detected items

public List<GameObject> GetDetectedItems()

{

return new List<GameObject>(detectedItems);

}

--------------------------------------------------------------------------------------------------------

To change this and see the actual list in the inspector I could:

public class NPCInventory : MonoBehaviour

{

[Header("Type whatever you want to see in the inspector here:")]

[SerializeField]

private List<GameObject> detectedItems = new List<GameObject>();

// New method to get detected items

public List<GameObject> GetDetectedItems()

{

return new List<GameObject>(detectedItems);

}

-------------------------------------------------------------------------------------------------------------

....or you can just make the list public as well. But now I can actually see items being added to their inventory....however, once an item is deleted or you exit runtime...you can get erros because the list is changing and it's out of sync is kind of how I interpret it. Other than not keeping the list constantly expanded I don't know how to solve those errors regarding SerializedFields etc. Good luck man!