error CS0120: An object reference is required to access non-static member `UnityEngine.Component.gameObject'

When I run this code,error CS0120: An object reference is required to access non-static member `UnityEngine.Component.gameObject’ error appears.
I am new at Unity and C#. So, I could not have any idea about solving this problem.
What can I solve this problem?

(not: I am working with Phidget RFID on Unity3d.)

static void rfid_Tag(object sender, TagEventArgs e)
{
Debug.Log("Tag “+ e.Tag+ " scanned”);
if (e.Tag == “0107ee83c1”) {
gameObject.renderer.material.color = Color.green;
}
}
}

1 Answer

1

This is a static method, but gameObject is an in
instance variable.

You need to Find the right GameObject, do without the tint or change the method to be non-static.