Unity error lookup
Paste anything from the Unity Console, one error or a whole screen of them. Each error links to a page with what it means, the causes worth checking first, and the fix in code. Obsolete-API warnings from a Unity 6 upgrade link to the matching upgrade page.
Paste Console output
Matches
Matches appear here as you paste. Nothing is sent anywhere. The three errors people paste most:
- NullReferenceException: Object reference not set to an instance of an object Runtime exception · Scripting
- MissingReferenceException: The object has been destroyed but you are still trying to access it Runtime exception · Scripting
- error CS0246: The type or namespace name could not be found Compiler error · Compiler
Runtime exceptions
-
NullReferenceException: Object reference not set to an instance of an objectYour code used a variable that holds nothing. -
MissingReferenceException: The object of type 'X' has been destroyed but you are still trying to access it.The object was destroyed, but your script kept a reference and used it afterwards. -
UnassignedReferenceException: The variable X of Y has not been assigned. You probably need to assign the X variable of the Y script in the inspector.A field that Unity serializes, a public field or one marked [SerializeField], is empty in the Inspector and your code used it. -
MissingComponentException: There is no 'X' attached to the "Y" game object, but a script is trying to access it.A script tried to use a component, such as a Rigidbody or Animator, on a GameObject that does not have one. -
IndexOutOfRangeException: Index was outside the bounds of the array.Your code read or wrote array position i, and i was negative or not less than the array's Length. -
ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.The same mistake as IndexOutOfRangeException, on a List instead of an array: the index was negative or not less than Count. -
You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. MonoBehaviours can only be added using AddComponent().A MonoBehaviour only works when it is attached to a GameObject, because Unity creates, updates and destroys it as part of that object. -
ArgumentException: The Object you want to instantiate is null.Instantiate was given null instead of a prefab or object to copy. -
Scene 'X' couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded.SceneManager.LoadScene can only load scenes that are in the build's scene list, even in the Editor's Play Mode. -
"SetDestination" can only be called on an active agent that has been placed on a NavMesh.The NavMeshAgent is not standing on a NavMesh it can use, or it is disabled, so it cannot plan a path. -
UnityException: Tag: X is not defined.Your code used a tag name, in CompareTag, FindWithTag or by setting gameObject.tag, that does not exist in the project's Tag Manager. -
ArgumentException: Input Axis X is not setup.Input.GetAxis and Input.GetButton look up their argument in the legacy Input Manager. -
Coroutine couldn't be started because the the game object 'X' is inactive!StartCoroutine was called on a MonoBehaviour whose GameObject, or one of its parents, is inactive. -
StackOverflowException: The requested operation caused a stack overflow.A method called itself, directly or through other methods, with nothing to stop it, until the call stack ran out. -
Look rotation viewing vector is zeroQuaternion.LookRotation was asked to face a direction of zero length. -
Parameter 'X' does not exist.Your script set an Animator parameter by name, and the controller on that Animator has no parameter with that exact name. -
Animator is not playing an AnimatorControllerYour script called SetBool, SetTrigger, Play or similar on an Animator that has no Animator Controller to run, so there is nothing for the call to affect. -
Failed to create agent because it is not close enough to the NavMeshA NavMeshAgent was enabled, and Unity could not find a NavMesh near enough to place it on. -
Destroying assets is not permitted to avoid data loss.Destroy was called on an asset in your project, almost always the prefab itself, instead of the copy Instantiate made. -
KeyNotFoundException: The given key was not present in the dictionary.Your code read dictionary[key] for a key the dictionary does not contain. -
InvalidOperationException: Collection was modified; enumeration operation may not execute.A foreach loop was walking through a list, dictionary or set, and something added or removed an item before the loop finished. -
Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported since Unity 5. If you want to use a non-convex mesh either make the Rigidbody kinematic or remove the Rigidbody component.A GameObject has a dynamic Rigidbody and a MeshCollider whose Convex box is unticked. -
UnityException: X is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead.Unity creates components while loading, sometimes off the main thread, before the engine is ready for API calls.
Compiler errors
-
error CS0246: The type or namespace name 'X' could not be found (are you missing a using directive or an assembly reference?)The compiler met a type name it does not know. -
error CS0103: The name 'X' does not exist in the current contextYou used a name, usually a variable, that is not declared where the code can see it. -
error CS0120: An object reference is required for the non-static field, method, or property 'X'You called something through the class name, PlayerHealth.TakeDamage(10), but TakeDamage belongs to each PlayerHealth component, not to the class. -
error CS0029: Cannot implicitly convert type 'X' to 'Y'You assigned a value of one type to a variable of another, and C# has no automatic conversion between them. -
error CS1061: 'X' does not contain a definition for 'Y' and no accessible extension method 'Y' accepting a first argument of type 'X' could be found (are you missing a using directive or an assembly reference?)The compiler looked for a member called Y on type X and found none. -
error CS0101: The namespace '<global namespace>' already contains a definition for 'X'Two classes with the same name exist in the same namespace. -
error CS1002: ; expectedA statement ended without a semicolon, so the compiler ran into the next token and stopped. -
error CS0115: 'X.Start()': no suitable method found to overrideA method is marked override, but the base class has no virtual or abstract method with that name and signature.
Editor messages
-
Can't add script component 'X' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match.Unity could not find a MonoBehaviour class in that file, so it has nothing to add. -
The referenced script (Unknown) on this Behaviour is missing!A GameObject or prefab has a component slot whose script Unity can no longer find. -
All compiler errors have to be fixed before you can enter playmode!At least one script in the project fails to compile, so Unity cannot run any of them.