Disabling a certain image
Hi guys,
I am trying to do an unlocking system but what i am struggling with is that whenever i finish a level the locked image won't disapear.I tried using image.enable=false; i tried gameObject.setActive(false); but nothing worked.
if (BoxTrigger.count == 0 && SceneManager.GetActiveScene().name == "Level1")
{
finished[0] = true;
if (finished[0])
{level2Button.interactable = true;
imagelv2.enabled = false;
Debug.Log("ffff"); }
}
I am setting my image in the inspector.
Thanks in advance
I forgot to mention that the log message "ffff " goes through
Answer by cupcakehox · May 12, 2018 at 04:07 AM
Okay I got it. Seems like I was trying to disable the image on another scene. Forgot that objects don't exist until scene actually starts.Silly me.Thanks for the answers.
Answer by tormentoarmagedoom · May 11, 2018 at 10:21 PM
Good day.
If what you say is true, or there is another script enabling it, or imagelv2 is not correctly assigned, and you are disabling another image.
Answer by vinilly · May 11, 2018 at 11:02 PM
I know you stated that you used gameObject.SetActive(false);
already but I am not able to examine the Variables.
Have you Tried;
GameObject.Find("imagelv2").SetActive(false);
or;
imagelv2.SetActive(false);
Your answer
![](https://koobas.hobune.stream/wayback/20220612162456im_/https://answers.unity.com/themes/thub/images/avi.jpg)