Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question ArgumentNullException: Value cannot be null. Parameter name: _unity_self

Discussion in 'Editor & General Support' started by leegod, May 2, 2023.

  1. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,345
    I am making 2d game using newest unity, 2022.2.17f1

    Now I met this error and this does not indicate any of my code's location, so can't know what is cause, can't debug, find any solution at googling.

    Please help, this is error message at console.

    ---------------
    ArgumentNullException: Value cannot be null.
    Parameter name: _unity_self
    UnityEditor.UIElements.Bindings.SerializedObjectList.get_Count () (at <68890c016c7a40d7ab0d5ba9aecf643f>:0)
    UnityEngine.UIElements.VerticalVirtualizationController`1[T].get_itemsCount () (at <6350d5f72ec34638985fbaab06c4c559>:0)
    UnityEngine.UIElements.DynamicHeightVirtualizationController`1[T].IsIndexOutOfBounds (System.Int32 i) (at <6350d5f72ec34638985fbaab06c4c559>:0)
    UnityEngine.UIElements.DynamicHeightVirtualizationController`1[T].CleanItemHeightCache () (at <6350d5f72ec34638985fbaab06c4c559>:0)
    UnityEngine.UIElements.DynamicHeightVirtualizationController`1[T].Refresh (System.Boolean rebuild) (at <6350d5f72ec34638985fbaab06c4c559>:0)
    UnityEngine.UIElements.BaseVerticalCollectionView.RefreshItems () (at <6350d5f72ec34638985fbaab06c4c559>:0)
    UnityEngine.UIElements.BaseVerticalCollectionView.UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize () (at <6350d5f72ec34638985fbaab06c4c559>:0)
    UnityEngine.GUIUtility: ProcessEvent(Int32, IntPtr, Boolean&)
     
  2. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,449
    I haven't seen that specific error before, but usually when I get an untraceable error it's because of some corrupted object in the scene.

    I would make a copy of your current project. In the copy, continually delete objects and refresh the console until the error goes away. Once the error goes away, then you know that the object that you deleted must have the error.

    There could also be a problem with the scene itself. I've also seen errors where an object in my scene seemed perfectly fine, but that object's prefab was corrupted.
     
    Angagsu-1 likes this.
  3. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,345
    What currupted means? hm... I don't know why I should do that cuz it seems unity internal error.
     
  4. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,449
    Some kind of bug in Unity caused an asset or scene object to become invalid data. Usually you can fix it by deleting the object and recreating it. Upgrading Unity versions is common source of these errors, but did you upgrade an existing project or did you begin your project in 2022.2.17f1? Even still, I find that the prefab workflow is complicated now, and I think they're still tweaking it, so it's a common source of errors for me.

    I cannot say for certain whether this is that cause of the error in your case. I was only suggesting that as something you could explore.

    That's almost certainly the root cause. If you can reproduce the problem reliably then you can file a bug report and hope they fix it.

    Unless you have source access and a lot of free time, there's no way to fix it. The only thing we can do is mitigate the consequences.
     
  5. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,345
    Thx, I am follower so I every time upgraded when new version come out. Wasn't experienced this phenomenon at previous versions.
     
  6. esco1979

    esco1979

    Joined:
    Mar 18, 2014
    Posts:
    136
    I have this same issue; I am using 2022.2.17f1; does it only happen when you hit play when some objects are selected in the inspector and have a script on them?
     
    anrelivant, HV-DY, E-wan15 and 23 others like this.
  7. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,345
    Didn't knew this. But I tested just now, yes it seems you are right.

    So now what is cause and how to resolve..
     
    theblitz and lara_victor02 like this.
  8. antonsenlarsen

    antonsenlarsen

    Joined:
    Nov 20, 2020
    Posts:
    4
    Might stem from the same issue that I had. When I changed values in a script on my prefabs they bugged out and all their references broke. This means that if you edit a prefab you have to re-reference that prefab in the editor to every single script every time. I had to roll back to LTS 2021 cause of it. It also threw me several other errors about Workers and Jobs.
     
  9. Frizzil

    Frizzil

    Joined:
    Aug 3, 2022
    Posts:
    5
    Yes, I'm experiencing the same thing. I can literally have an empty script on an otherwise empty GameObject with one field and I'll get this error on play start. Script:


    Code (CSharp):
    1.  
    2. using UnityEngine;
    3.  
    4. public class Test : MonoBehaviour {
    5.  
    6.     public int HelloWorld = 2;
    7.  
    8. }
    9.  
    Interestingly, removing the field prevents the error (though that's obviously no workaround).

    EDIT: Updating to 2022.2.18f1 fixed it.
     
    Last edited: May 6, 2023
    acnestis likes this.
  10. ghellee

    ghellee

    Joined:
    Dec 6, 2017
    Posts:
    5
    I am experiencing the same issue with 2022.2.21
     
  11. alpha_nexus

    alpha_nexus

    Joined:
    Jun 23, 2016
    Posts:
    1
    I have this issue on 2022.3.3f1. It's pretty annoying. I started a fresh project and pulled over objects from my old 2019.3.11f project. If I select my gameobject, that I'm using as a singleton to track the game state, and hit "Play". I get the same error:

    Code (CSharp):
    1.  
    2. ArgumentNullException: Value cannot be null.
    3. Parameter name: _unity_self
    4. UnityEditor.SerializedObject.FindProperty (System.String propertyPath) (at /Users/bokken/build/output/unity/unity/Editor/Mono/SerializedObject.bindings.cs:74)
    5. UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.BindPropertyRelative (UnityEngine.UIElements.IBindable field, UnityEditor.SerializedProperty parentProperty) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Editor/Bindings/BindingExtensions.cs:169)
    6. UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.BindTree (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Editor/Bindings/BindingExtensions.cs:113)
    7. UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.ContinueBinding (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Editor/Bindings/BindingExtensions.cs:39)
    8. UnityEditor.UIElements.Bindings.DefaultSerializedObjectBindingImplementation+BindingRequest.Bind (UnityEngine.UIElements.VisualElement element) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Editor/Bindings/BindingExtensions.cs:1126)
    9. UnityEngine.UIElements.VisualTreeBindingsUpdater.Update () (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Bindings/VisualTreeBindingsUpdater.cs:272)
    10. UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/VisualTreeUpdater.cs:111)
    11. UnityEngine.UIElements.Panel.UpdateBindings () (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Panel.cs:1002)
    12. UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.UpdateSchedulers () (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/UIElementsUtility.cs:256)
    13. UnityEngine.UIElements.UIEventRegistration.UpdateSchedulers () (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/UIElementsUtility.cs:105)
    14. UnityEditor.RetainedMode.UpdateSchedulers () (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Editor/RetainedMode.cs:55)
    15.  
    However, if I don't have that object selected, I can hit "Play" and it runs fine. I'm not sure if this is a bug with the latest unity or in my code, but this code has been working in my Unity2019 project for years.
     
  12. Avalin

    Avalin

    Joined:
    Oct 12, 2018
    Posts:
    98
    Pretty sure this is a bug from the newest Unity. I also never have seen this bug before, until I just upgraded to 2022.3.3f1, and there's been no remarkable new changes to my project. I noticed these errors come and go, so sometimes they don't show for a while, then they come back.
     
  13. kronugin

    kronugin

    Joined:
    Jan 27, 2023
    Posts:
    1
    Can confirm that this was the case for me but would also add that disabling objects helped to find the issue too, didn't have to delete them.

    In my case restarting a project helped remove the errors but they always came back after a while. Using Unity 2022.3.3f1.

    Actually, this is 100% true for me. Errors appear when I select an object before launching the scene. Strange things lurk ahead.
     
    Last edited: Jun 26, 2023
  14. yumupdate

    yumupdate

    Joined:
    Nov 20, 2012
    Posts:
    30
    I'm experiencing this issue intermittently as well. Wish I knew how to reproduce it, but all advice on attempting to reproduce and/or fix it have thus far failed. I'm not going down a list of 100s of items disabling/re-enabling things when I can't even faithfully reproduce the problem.

    Code (CSharp):
    1. ArgumentNullException: Value cannot be null.
    2. Parameter name: _unity_self
    3. UnityEditor.UIElements.Bindings.SerializedObjectList.get_Count () (at <9f0f853070524c139e10a85a1cfcedb6>:0)
    4. UnityEngine.UIElements.VerticalVirtualizationController`1[T].get_itemsCount () (at <735c071c072642ad8d077fa38c650a28>:0)
    5. UnityEngine.UIElements.DynamicHeightVirtualizationController`1[T].IsIndexOutOfBounds (System.Int32 i) (at <735c071c072642ad8d077fa38c650a28>:0)
    6. UnityEngine.UIElements.DynamicHeightVirtualizationController`1[T].CleanItemHeightCache () (at <735c071c072642ad8d077fa38c650a28>:0)
    7. UnityEngine.UIElements.DynamicHeightVirtualizationController`1[T].Refresh (System.Boolean rebuild) (at <735c071c072642ad8d077fa38c650a28>:0)
    8. UnityEngine.UIElements.BaseVerticalCollectionView.RefreshItems () (at <735c071c072642ad8d077fa38c650a28>:0)
    9. UnityEngine.UIElements.BaseVerticalCollectionView.UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize () (at <735c071c072642ad8d077fa38c650a28>:0)
    10. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
     
  15. NoahHarteHeckmann

    NoahHarteHeckmann

    Joined:
    Apr 11, 2021
    Posts:
    1
    Seems to happen when a GameObject with a script is selected (as another user suggested). I also noticed (might be a coincidence) that the number of error messages given after pressing play was the same number of [SerializedField]'s that the particular selected GameObject had under the Script component. Maybe "[SerializedField]'s is wrong but I mean all the places where you can edit stuff and drag and drop.
     
  16. D-XII

    D-XII

    Joined:
    Jul 11, 2019
    Posts:
    5
    I'm getting the same errors on 2022.3. Seems to be related to [SerializeField] possibly or just serialized arrays. I started getting this when I switched the location of one of my arrays in the code. If I have the gameobject with the script selected then the error pops up on play, if not it runs as normal.
     
    Tronyc, acnestis and Aekila like this.
  17. Snedden27

    Snedden27

    Joined:
    Jul 4, 2020
    Posts:
    8
    Having this show up out of no where every now and then, I have 2022.3.2f1 LTS, it goes away after a while by itself or when I restart the unity editor :

    Code (CSharp):
    1. ArgumentNullException: Value cannot be null.
    2. Parameter name: _unity_self
    3. UnityEditor.SerializedObject.FindProperty (System.String propertyPath) (at <ac87b54e58ee4be198261fd5c8030d52>:0)
    4. UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.BindPropertyRelative (UnityEngine.UIElements.IBindable field, UnityEditor.SerializedProperty parentProperty) (at <9f0f853070524c139e10a85a1cfcedb6>:0)
    5. UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.BindTree (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at <9f0f853070524c139e10a85a1cfcedb6>:0)
    6. UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.ContinueBinding (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at <9f0f853070524c139e10a85a1cfcedb6>:0)
    7. UnityEditor.UIElements.Bindings.DefaultSerializedObjectBindingImplementation+BindingRequest.Bind (UnityEngine.UIElements.VisualElement element) (at <9f0f853070524c139e10a85a1cfcedb6>:0)
    8. UnityEngine.UIElements.VisualTreeBindingsUpdater.Update () (at <735c071c072642ad8d077fa38c650a28>:0)
    9. UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase) (at <735c071c072642ad8d077fa38c650a28>:0)
    10. UnityEngine.UIElements.Panel.UpdateBindings () (at <735c071c072642ad8d077fa38c650a28>:0)
    11. UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.UpdateSchedulers () (at <735c071c072642ad8d077fa38c650a28>:0)
    12. UnityEngine.UIElements.UIEventRegistration.UpdateSchedulers () (at <735c071c072642ad8d077fa38c650a28>:0)
    13. UnityEditor.RetainedMode.UpdateSchedulers () (at <9f0f853070524c139e10a85a1cfcedb6>:0)
     
    GamerFawn likes this.
  18. TealcWu

    TealcWu

    Joined:
    Nov 26, 2013
    Posts:
    7
    Yes, repro on 2022.3.0f1 while selecting an object with script in Hierarchy.
    Work around: select none object in Hierarchy when pressing Play.
     
  19. toyhunter

    toyhunter

    Joined:
    Mar 5, 2018
    Posts:
    76
    Same here, love Unity even more
     
  20. Syco753

    Syco753

    Joined:
    Feb 11, 2013
    Posts:
    42
    great. thanks - solved the issue :)
     
    Farsam likes this.
  21. BasicDeveloper_100

    BasicDeveloper_100

    Joined:
    Jun 28, 2023
    Posts:
    3
    can't you just use re-import all?
     
  22. BasicDeveloper_100

    BasicDeveloper_100

    Joined:
    Jun 28, 2023
    Posts:
    3
    its under assets at the bar at the top
     
  23. BasicDeveloper_100

    BasicDeveloper_100

    Joined:
    Jun 28, 2023
    Posts:
    3
  24. Th3_Spectre

    Th3_Spectre

    Joined:
    Apr 3, 2023
    Posts:
    5
    This is exactly whats happening to me with version 2022.3.4f1
     
  25. evyatron

    evyatron

    Joined:
    Jul 20, 2014
    Posts:
    132
    Same here, 2022.3.4f1 LTS as well.
     
    Revanite_MobX2002 likes this.
  26. QuakeDev_Kr

    QuakeDev_Kr

    Joined:
    Apr 17, 2020
    Posts:
    2
    I'm also seeing the same message in Unity 2022.3.4f1 LTS version.
    I'm getting this error even though I have only a few lines of code in my new project.
    In my case, I created a ScriptableObject class and it seems that the error is caused by an object that I initialized as null in one of its properties.
    Here's my code:

    Code (CSharp):
    1.  
    2. public class ModeSettings : ScriptableObject
    3. {
    4.     // ...
    5.     [Header("[Prefabs]")]
    6.     public GameObject TempObj = null;
    7.     // ...
    8. }
    9.  
     
  27. Revanite_MobX2002

    Revanite_MobX2002

    Joined:
    Dec 19, 2021
    Posts:
    1
    Same here, 2022.3.4f1 LTS as well. Caused everytime I apply rigidbody movement it seems
     
  28. unity_0GlwZ4j_Ggr0lA

    unity_0GlwZ4j_Ggr0lA

    Joined:
    Nov 30, 2019
    Posts:
    8
    Same issue in 2022.3.5f1
     
  29. MichaelAJohnston

    MichaelAJohnston

    Joined:
    Oct 10, 2021
    Posts:
    1
    I am also getting this error:

    ArgumentNullException: Value cannot be null.
    Parameter name: _unity_self

    I started seeing it with version 2022.3 LTS. I've upgraded Unity with each update and am now on 2022.3.5f1. And am still getting it. It only happens when I have an object with a script selected and I press Play. It looks like it causes the Inspector to not render everything for the script. Also happens in Debug view.
     
    williamdoc and breylinlee like this.
  30. luukbraijmakers

    luukbraijmakers

    Joined:
    Feb 11, 2021
    Posts:
    7
    I put my entire project in a package and then made a new project with a downgrade to 2021.3.28f1. That worked for me!

    Hopefully, you have something with this information.
     
  31. thiyageshvenkat

    thiyageshvenkat

    Joined:
    Feb 2, 2020
    Posts:
    3
    The problem seemed to fix itself for me.

    Edit: It seems to be caused for me when public static is used
     
    Last edited: Jul 22, 2023
  32. unity_0GlwZ4j_Ggr0lA

    unity_0GlwZ4j_Ggr0lA

    Joined:
    Nov 30, 2019
    Posts:
    8
    I've found it to be an intermittent issue. However, I've found that it is much easier to make the error happen if you rapidly and repeatedly run your mouse pointer up and down over a number of public fields in the inspector while the program is 'booting up' in play mode.
     
  33. thiyageshvenkat

    thiyageshvenkat

    Joined:
    Feb 2, 2020
    Posts:
    3
    I think the best way to fix the problem is to save everything and restart unity, or change code to an equivalent code
     
    acnestis likes this.
  34. MelvinG24

    MelvinG24

    Joined:
    Jan 30, 2022
    Posts:
    2
    That is the most stupid Error message I have ever got in Unity. I can not believe it was because of that :D:D:D

    Thank you very much, it actually works!:cool:
     
  35. breylinlee

    breylinlee

    Joined:
    May 4, 2019
    Posts:
    10
    got this problem too on 2022.3.0f1c1.
    Thank you, you save my day! The Debug view is the point.

    And for those who doesn't know what is a Debug view: https://pixeleuphoria.com/blog/index.php/2020/05/01/unity-tip-view-real-recttransform-values/
     
    Last edited: Jul 27, 2023
  36. zakirshikhli

    zakirshikhli

    Joined:
    Apr 8, 2016
    Posts:
    18
    I confirm same issue on 2022.3.5f1 LTS
    "Seems to happen when a GameObject with a script is selected" is true.
     
  37. RasmusMolckNilsson

    RasmusMolckNilsson

    Joined:
    May 14, 2021
    Posts:
    6
    Inspecting a scriptable object while pressing play will also result in this error, at least if the scriptable object has some combination of references to other scriptable objects, like this:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections.Generic;
    3.  
    4. public class S1 : ScriptableObject
    5. {
    6.     public List<S2> listOfScriptableObjects;
    7.  
    8.     public S2 singleScriptableObject;
    9. }
     
  38. wechat_os_Qy0xDfW7_FXo5lVaICGD12FD8

    wechat_os_Qy0xDfW7_FXo5lVaICGD12FD8

    Joined:
    Jul 9, 2023
    Posts:
    5
    thanks, got the same issue too and solved it by stopping inspecting a scriptable object then clicking Play game
     
  39. RasmusMolckNilsson

    RasmusMolckNilsson

    Joined:
    May 14, 2021
    Posts:
    6
  40. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    901
    2022.3.1f1.

    I have a controller object with 'Don't Destroy on Load'. If I have it selected and play, I get 16 of these errors. If I select a different object and play, no errors. If while running I select this object, also no errors.

    My guess is as the object moves to DontDestroyOnLoad, the inspector has lot all its pointers for a draw.
     
  41. jorool

    jorool

    Joined:
    Sep 17, 2019
    Posts:
    1
    The same issue in 2022.3.6f1, I hope this does nothing to our game.
     
  42. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    660
    I don't think that can be the case, I have been getting this error since I migrated from 2021.3.23 to 2022.3.3... No errors appeared during the file migration process, also no errors appeared until after I played the game for a few times, then I migrated to 2022.3.4 the errors were gone for a few hours but then started to appear again, the first time appeared 4 times in the console, next day there were 6, then 8 , then 16, then 24, then 36... and the number of times the error showed up increased with every passing day, then I migrated to 2022.3.5 and the errors were gone again, but after a while they started to appear again, and once again, there were 4 messages first, then 8, then 10, 12, 16, 24 and so on. This morning I just migrated to 2022.3.6, haven't seen these errors so far, but if other people have seen it in this version, then most likely I see those again tomorrow.
     
  43. Gustjc

    Gustjc

    Joined:
    Oct 16, 2017
    Posts:
    9
    I also had this issue in 2022.3.6f1.
    But in my case it was happening with a Serializable StateMachine custom class I had inside my Enemy Controller.
    Same issue, only go the errors when pressing play with the object selected.
    The strange thing is that it was originally okay, then after changing some seemingly unrelated code, it started happening.

    It seems like it went away after restarting the editor in my case.
    But still made me lose quite a bit of time to figure out what was actually happening.
     
  44. MindGem

    MindGem

    Joined:
    May 11, 2017
    Posts:
    84
    That is exactly it. With zero changes. The program crash if one object is selected in the hierarchy and then 1 sec later you deselect the object and play again and it works. So clearly a Unity bug.

    Now..is there any stable version of Unity that anyone know that doesn't have this issue?
    Im a newbie and when the game crashes 200 times a second I obiously thought it was a bug I've made but now I realize I spent a week with this damn unity bug instead.
     
  45. skyrod92

    skyrod92

    Joined:
    Sep 13, 2022
    Posts:
    4
    Same issue in 2022.3.6f1 and simply fixed by reimporting all
     
  46. bisewski

    bisewski

    Joined:
    Jan 16, 2014
    Posts:
    212
    Same issue in 2022.3.7f1
     
  47. infinity8208

    infinity8208

    Joined:
    Mar 26, 2022
    Posts:
    1
    I guess it happens when you assign a public value both in scrip and in unity. Because sometimes value differs so just make those value public which you want to change frequently and make those values private which you want to do calculation and loops .It worked for me i made values which i dont want to change in unity private and the error was gone and just dont assign value to public variables in script.Sorry if i am wrong, i am just a beginner to unity.
     
  48. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,345
    problem is, at past unity version, this error does not appeared even if the cause exist you write here.
     
  49. sgamerw

    sgamerw

    Joined:
    Dec 11, 2018
    Posts:
    2
    the same error and the same unity version.
     
  50. Char13s

    Char13s

    Joined:
    May 26, 2019
    Posts:
    1
    So I had debug mode toggled on and was getting this error randomly outa nowhere, then I turned off and pressed play, without touching anything else and it went away, repeated this process 5 times just to mess with unity, and the same thing happened, when its on, random ass error, when its not, everything is just fine.... not sure if this helps anyone else. Im using Unity 2022.3.5f1
     
    tan0929 likes this.