[SOLVED] Beginner question : The type or namespace name `RawImage' could not be found

Hi,

I’m new to Unity and i’m sure this is a really simple but…this code give me this error and I can’t find why since RawImage is class from Unity UI :
error CS0246: The type or namespace name `RawImage’ could not be found. Are you missing a using directive or an assembly reference?

using UnityEngine;
using System.Collections;

public class get_web_images : MonoBehaviour {
    public string url = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg";
    // Use this for initialization
    IEnumerator Start () {
        RawImage ri;
        ri = gameObject.AddComponent<RawImage>();
    }
   
}

thanks

using UnityEngine.UI

1 Like

As @hpjohn said, put using UnityEngine.UI; at the top with your other using statements.

Additionally, if you right click on the red highlighted class in MonoDevelop, often it will have refactoring suggestions in order to fix the problem. In this case, if you click “Resolve” in the right click menu, it will have an option to add the using statement automatically.

1 Like

Thanks !!!

RawImage still gives an error for me even with

using UnityEngine.UI;

actually nevermind i was trying to accses “sprite” of a “RawImage” and judt read the error wrong