I added an Image to the Canvas but my Debug.Log() displays 0 Length when I call canvas.GetComponent().
GameObject canvas = GameObject.Find("Canvas");
crosshair = canvas.GetComponents<Image>();
Debug.Log("Canvas null? " + (canvas == null).ToString());
Debug.Log("CrossHair " + crosshair.Length);
Canvas is not null, but it does not have any Image in it.
In the design view of Unity, I can clearly see the Image which is a child of the Canvas.
Did I do something wrong here?
Any help will be appreciated, thanks.
Yes, you are doing wrong. Your Image component is on Image object, not on Canvas. Do it this way:
GameObject canvas = GameObject.Find("Image");