- Home /
Question by
JerryVonJingles · Jun 03, 2015 at 12:52 PM ·
uiimagedisableenable
Image.enable not working properly
I need to disable images on the startup of a scene. I have image variables that are referenced through the editor. These variables will not enable or disable and I do not know why. Here is the code:
public int sceneToLoad = 0;
public Image ocean;
public Image cell;
void awake()
{
ocean.enabled = false;
cell.enabled = false;
}
public void StartLevel()
{ Application.LoadLevel (sceneToLoad); }
public void rightArrow()
{ sceneToLoad++; }
public void leftArrow()
{ sceneToLoad--; }
void update()
{
if (sceneToLoad == 0)
cell.enabled = true;
else if (sceneToLoad == 1)
ocean.enabled = true;
}
}
Comment
Best Answer
Answer by Landern · Jun 03, 2015 at 12:53 PM
The unity engine method/functions are case sensitive, in your case the problem is just words.
public int sceneToLoad = 0;
public Image ocean;
public Image cell;
void Awake() // upper case A for Awake
{
ocean.enabled = false;
cell.enabled = false;
}
public void StartLevel()
{ Application.LoadLevel (sceneToLoad); }
public void rightArrow()
{ sceneToLoad++; }
public void leftArrow()
{ sceneToLoad--; }
void Update() // upper case U for Update
{
if (sceneToLoad == 0)
cell.enabled = true;
else if (sceneToLoad == 1)
ocean.enabled = true;
}
}
Without it properly named the Unity Engine state machine will not call the methods on the scripts.