Hi everybody, I made a 2d (URP) scene for Unity 2022.3.5f1 to make a simple prototype. But when I try to enter the victory trigger (pasted below) with my player I got the error: ArgumentNullException: Value cannot be null. Parameter name: _unity_self
How can Unity itself give a Null Exception? And how can I fix this?
Victory Trigger script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class VictoryTrigger : MonoBehaviour
{
private void OnTriggerEnter(Collider collider)
{
Debug.Log("Working");
if (collider.CompareTag("Player"))
{
Debug.Log("Enter Code");
SceneManager.LoadScene("MainMenu");
}
}
}
Before asking: Yes the player has the player tag, and yes there is a scene (in the build settings) with the name MainMenu. The debugs do not get written down.
Entire Error:
ArgumentNullException: Value cannot be null.
Parameter name: _unity_self
UnityEditor.SerializedObject.FindProperty (System.String propertyPath) (at :0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.BindPropertyRelative (UnityEngine.UIElements.IBindable field, UnityEditor.SerializedProperty parentProperty) (at <68ddc6fd093848298397957a5969af5e>:0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.BindTree (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at <68ddc6fd093848298397957a5969af5e>:0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.ContinueBinding (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at <68ddc6fd093848298397957a5969af5e>:0)
UnityEditor.UIElements.Bindings.DefaultSerializedObjectBindingImplementation+BindingRequest.Bind (UnityEngine.UIElements.VisualElement element) (at <68ddc6fd093848298397957a5969af5e>:0)
UnityEngine.UIElements.VisualTreeBindingsUpdater.Update () (at :0)
UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase) (at :0)
UnityEngine.UIElements.Panel.UpdateBindings () (at :0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.UpdateSchedulers () (at :0)
UnityEngine.UIElements.UIEventRegistration.UpdateSchedulers () (at :0)
UnityEditor.RetainedMode.UpdateSchedulers () (at <68ddc6fd093848298397957a5969af5e>:0)
I can also place down the 2d Movement Script I use, but I don’t think that makes any difference.
Thanks for reading!