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 gunInventory : MonoBehaviour {
- public GameObject[] gunsList = new GameObject[5];
- public bool[] guns = new bool[] {true, false, false, false, false};
- public KeyCode[] keys = new KeyCode[] {KeyCode.Alpha1, KeyCode.Alpha2, KeyCode.Alpha3, KeyCode.Alpha4, KeyCode.Alpha5};
- public int maxGuns = 1;
- public void addGun(int number){
- guns [number] = true;
- maxGuns++;
- }
- void Update(){
- for (int i = 0; i < keys.Length; i++) {
- if(Input.GetKeyDown(keys[i]) && guns[i]){
- hideGuns();
- gunsList[i].SetActive(true);
- }
- }
- }
- public void hideGuns(){
- for(int i = 1; i < maxGuns + 1; i++){
- gunsList[i].SetActive(false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement