I am trying to make a script so when you pick up an object, a checkmark shows up. The way I want to do this is by disabling the Image component on the Checkmark UI, and when IngredientCollected is true, have the checkmark show up by activation the Image component again. How could I do this? This is what I have so far.
Also, I don’t know if this will help you understand the code better or not but the public PickUp1 pickup1 is me accessing the variable IngredientCollected from that script and using it in this CollectCheck script.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
public class CollectCheck : MonoBehaviour
{
public PickUp1 pickup1;
public Image checkmark;
void Start()
{
checkmark = GetComponent<Image>();
checkmark.visible = false;
}
void Update()
{
if (pickup1.IngredientCollected == true)
{
checkmark.visible = true;
}
}
}