if have a script that is supposed to opens (sets active) an image and sets a bool to true when I click I and does the opposite when I click it again but It doesn’t work, it doesn’t change the bool or set SetActive to true I don’t know what’s wrong with it.
heres my script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Crafting : MonoBehaviour {
public bool isOpen;
public void Start(){
gameObject.SetActive (false);
isOpen = false;
}
void Update () {
if (Input.GetKeyDown (KeyCode.I) && !isOpen) {
gameObject.SetActive (true);
isOpen = true;
}
if (Input.GetKeyDown (KeyCode.I) && isOpen) {
gameObject.SetActive (false);
isOpen = false;
}
}
}