Search Unity

Error in Editor Scripting Tutorial

Discussion in 'Community Learning & Teaching' started by Gdizzie, Jul 28, 2019.

  1. Gdizzie

    Gdizzie

    Joined:
    Apr 4, 2013
    Posts:
    6
    I found this code in the Editor Scripting Tutorial.

    Code (CSharp):
    1. public class NameBehaviour : MonoBehaviour
    2. {
    3.     public string Name;
    4.  
    5.     [ContextMenu("Reset Name")]
    6.     private static void ResetName()
    7.     {
    8.         Name = string.Empty;
    9.     }
    10. }
    Error on line 8: An object reference is required for the non-static field, method, or property 'NameBehaviour.Name'
     
    Last edited: Jul 28, 2019