'type' does not contain a definition for 'identifier'

This error is given when a type does not contain a member that is attempting to be referenced.


Search in code and documentation#

  1. Make sure you have autocomplete and errors underlined in red. A configured IDE is a requirement.
  2. Check with autocomplete for versions of the member you wanted to access.
  3. If the member cannot be found, make sure it is present in the Script Reference relevant to your version of Unity, or the relevant Package Docs associated with the package the code should be in.

I am sure the member should be present#


Make sure you don't have a type with the same name as the target type!

You can figure out whether this is the case by using your IDE's Go To Declaration feature.

I have a type with the same name#

Your options for fixing this error are:

  1. Rename your type to avoid the conflict.
  2. Access the correct type via its namespace. UnityEngine.Cursor for example.
  3. Specify the correct type as a using statement. using Cursor = UnityEngine.Cursor; for example.

I don't have a type with the same name#

Either the type does not have the member in your version, or you do mistakenly have a type with the same name.