Hello,
I am trying to update the source file on an image object inside of a canvas, but get an error when I try to use the GetComponent<> method.
I originally wrote my UpdateColor() method to work with a sprite renderer component and not working with the UI or canvas objects. And when I tried rewriting it to use the components in the Image UI object I hit a wall : (
void UpdateColor(GameObject p1, Sprite p2)
{
//update a specific gameobject with the sprite sent as a parameter
Debug.Log("gameobject: " + p1);
Debug.Log("image component:" + p1.GetComponent<Image>().sprite);
//p1.GetComponent<Image>().sprite = p2;
}
here is the object in the inspector
and the error I keep getting