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

UI Image

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

  1. TheNoobieWaffle

    TheNoobieWaffle

    Joined:
    Jul 12, 2014
    Posts:
    27
    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:
    27
    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:
    27
    SOLVED:

    you need this:

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

    Shine_Bolt

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