Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

r20 Image.sprite is not exposed?

Discussion in 'UGUI & TextMesh Pro' started by ina, Nov 2, 2014.

  1. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,058
    how do you assign a sprite at runtime to an ui image in r20?

    error CS1061: Type `Image' does not contain a definition for `sprite' and no extension method `sprite' of type `Image' could be found (are you missing a using directive or an assembly reference?)
     
  2. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    From what i can see it is exposed "public Sprite sprite" that is directly from the Image class itself.
     
    Darkheinrich likes this.
  3. RajivSK

    RajivSK

    Joined:
    Jan 10, 2015
    Posts:
    1
    I had the same issue but noticed it was because of a type conflict. Try using UnityEngine.UI.Image instead.

    I realise the question is a bit dated but I ended up here when I ran into the same issue. Maybe it can help someone in the future.
     
  4. Aishwarya123

    Aishwarya123

    Joined:
    Mar 17, 2017
    Posts:
    1
    I also have the same error
    could you people help me plss??
    error CS1061: Type `Image' does not contain a definition for `sprite' and no extension method `sprite' of type `Image' could be found (are you missing a using directive or an assembly reference?)
     
  5. Darkheinrich

    Darkheinrich

    Joined:
    Mar 9, 2020
    Posts:
    1
    you are a genius you solutionate my problem you are my lord