Search Unity

UI Image

Discussion in 'Scripting' started by TheNoobieWaffle, Nov 10, 2014.

  1. TheNoobieWaffle

    TheNoobieWaffle

    Joined:
    Jul 12, 2014
    Posts:
    28
    This does not work:
    UIStamina.GetComponent<image>().fillAmount = .5f;

    Trying to set the fill amount of an image component from a specified gameobject to .5f. Not working, how can I fix this?
     
  2. TheNoobieWaffle

    TheNoobieWaffle

    Joined:
    Jul 12, 2014
    Posts:
    28
    The thing is, the new unity documentation has this:


    Image image = GetComponent<Image>();

    but, for some reason my MonoDevelop sees "Image" as an error. I have the most up to date version of Unity and MonoDevelop on my computer, but I also have the old versions as well. I am indeed running the most updated verions of both.
     
  3. TheNoobieWaffle

    TheNoobieWaffle

    Joined:
    Jul 12, 2014
    Posts:
    28
    SOLVED:

    you need this:

    using UnityEngine.UI;
     
    JoeStrout likes this.
  4. Shine_Bolt

    Shine_Bolt

    Joined:
    Apr 13, 2018
    Posts:
    4
    Thank You!!