Search Unity

Problem Using Image

Discussion in 'Immediate Mode GUI (IMGUI)' started by abgamers, Jan 26, 2015.

  1. abgamers

    abgamers

    Joined:
    Dec 22, 2009
    Posts:
    97
    Hi,

    I'm trying to access new Image class, but for some reason its throwing following error:
    Additional Note: I'm using Free version of Unity on mac, not sure if thats the problem.

    The code is pretty simple its kind of healthbar which need to increase of decrease depending on value passed.
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. public class ShowCurrentUpgrade : MonoBehaviour {
    5.     public void UpdateUpgradeLevel( int Level )   {
    6.         Image img = getComponent<Image>();
    7.         img.fillAmount = Level/10;
    8.     }
    9. }
    10.  
    Please help me to fix the problem

    Thanks