using System.Collections; using System.Collections.Generic; using UnityEngine; public class keyWhenPressed : MonoBehaviour { public GameObject objectToActivate; public GameObject _LevelManager1; private ButtonDOne script1; public GameObject _LevelManager2; private ButtonDTwo script2; public GameObject _LevelManager3; private ButtonDThree script3; public bool isActivated; private void Awake() { // Disable the object by default objectToActivate.SetActive(false); } private void Update() { script1 = _LevelManager1.GetComponent(); script2= _LevelManager2.GetComponent(); script3 = _LevelManager3.GetComponent(); bool eins = script1.einsAn; bool zwei = script2.zweiAn; bool drei = script3.dreiAn; // Check if all three conditions are true and the object is not yet activated if (eins && zwei && drei && !isActivated) { // Activate the object objectToActivate.SetActive(true); isActivated = true; } } }