The original address: https://support.unity3d.com/hc/en-us/articles/206496883-What-is-CS0120-
symptoms
I got the following error on the Console:
Error CS0120: An object reference is required to access non-static member ‘__’
why
There are two situations that can cause this error, listed below:
This error occurs when ol> attempts to directly reference a non-static variable in a static method.
The error message given in this example is:
Error CS0120: An object reference is required to access non-static member ‘myscript.name’
This error occurs when ol> calls another non-static method in a static method.
The error message given in this example is:
Error CS0120: An object reference is required to access non-static member ‘myscript.methodb ()’
The solution
- CS0120 can be resolved by creating an instance that references this non-static variable:
- CS0120 can be resolved by creating an instance that references this non-static method:
For more information
https://msdn.microsoft.com/en-us/library/s35hcfh7.aspx
Read More:
- Error cs1010 cs8025 cs1012 cs1525 common document error resolution
- What is cs1525 error
- The build report plug-in reported an error in importing unit script (BRT_ Util.cs :error CS1525: Unexpected symbol `;’, expecting `)’, or `,’)
- Unity report error CS0619: ‘XRDevice.isPresent’ is obsolete
- Unity2019.1.02f error cs0104: ‘minattribute’ is an ambiguous reference between
- Unity reports an error cs0619: ‘guitexture’ is obsolete
- Adobe Photoshop CS6 download and installation and error:16 The solution of
- Photoshop CS6 detailed installation of graphic tutorial
- Generate template asp.net Cs1010: newline in constant
- [reprint] method to solve error 16 in illustrator CS6
- Compiler error message: cs1056: unexpected character handling
- [Fixed] Unity error CS1704: An assembly with the same name `UnityEngine.UI’ has already been imported
- Unity WebGL error CS0117: ‘NetworkTransport’ does not contain a definition for ‘SetMulticastLock’
- Unity development memo 000025: error cs0433: the type ‘task’ exists in both ‘xxx’ and ‘YYY’
- error CS0234: The type or namespace name ‘UI‘ does not exist in the namespace ‘UnityEngine‘
- About error CSC in c# vs: error cs0006: metadata file could not be found
- Unity3D error CS0227: Unsafe code may only appear if compiling with /unsafe…
- Error cs1002:; expected error resolution
- In Java, int is converted to string, and zero is added before the number of bits is insufficient
- When the spring MVC project is running on idea, an error is reported when the controller is a null pointer