Reputation: 11
I'm creating a game for an assignment using Unity. I want to have a light change color when a specific object gets next to it.
I am getting an error saying
"Error CS1061 'Light' does not contain a definition for 'color' and no extension method 'color' accepting a first argument of type 'Light' could be found (are you missing a using directive or an assembly reference?)"
Every website I read said there is a Light.color
, including the Unity documentation. Every one of them has different issues regarding Light.color
.
Code:
Light lc = other.gameObject.transform.parent.gameObject.GetComponent<Light>();
lc.color = Color.green;
All I want to change the color of light without getting an error.
Upvotes: 1
Views: 576
Reputation: 139
By default, new scripts created via the Unity Editor will have "using UnityEngine" near the beginning.
The 'Light' you are referring too is a native Unity object, and thus you either need to include "using UnityEngine" or reference the object as UnityEngine.Light
It is not a fault of theirs to not mention this in the documentation, as everything in the documentation is assumed to be part of the UnityEngine API.
Upvotes: 1
Reputation: 11
Nvmd, fixed it
if anyone else gets this problem, it is probably because Unity forgot to mention in its documentation that is it: UnityEngine.Light not: Light
Upvotes: 0