Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class DoorSetActive : MonoBehaviour
- {
- [SerializeField]
- public GameObject[] switches;
- int numOfSwitches = 0;
- private void Update()
- {
- GetNumOfSwitches();
- GetSwitchDoor();
- }
- public int GetNumOfSwitches()
- {
- int num = 0;
- for (int i = 0; i <= switches.Length; i++)
- {
- numOfSwitches = num;
- if (switches[i].GetComponent<DoorSwitch>().isPressed == false)
- num++;
- else if (switches[i].GetComponent<DoorSwitch>().isPressed == true)
- numOfSwitches--;
- //return numOfSwitches;
- }
- return numOfSwitches;
- }
- public void GetSwitchDoor()
- {
- if (numOfSwitches <= 0)
- {
- Destroy(this.gameObject);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement