Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class InventorySystem : MonoBehaviour
- {
- public static InventorySystem Instance { get; set; }
- public GameObject inventoryScreenUI;
- public bool isOpen;
- private void Awake()
- {
- if (Instance != null && Instance != this)
- {
- Destroy(gameObject);
- }
- else
- {
- Instance = this;
- }
- }
- void Start()
- {
- isOpen = false;
- }
- void Update()
- {
- if (Input.GetKeyDown(KeyCode.I) && !isOpen)
- {
- Debug.Log("i is pressed");
- inventoryScreenUI.SetActive(true);
- Cursor.lockState = CursorLockMode.None;
- isOpen = true;
- }
- else if (Input.GetKeyDown(KeyCode.I) && isOpen)
- {
- inventoryScreenUI.SetActive(false);
- Cursor.lockState = CursorLockMode.Locked;
- isOpen = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement