Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class CanvasSwitch : MonoBehaviour {
  6.  
  7.     public Canvas HUD;
  8.     public Canvas Inventory;
  9.  
  10.     bool temp = false;
  11.  
  12.     // Use this for initialization
  13.     void Start () {
  14.         HUD.GetComponent<Canvas>().enabled = true;
  15.         Inventory.GetComponent<CanvasSwitch>().enabled = false;
  16.     }
  17.    
  18.     // Update is called once per frame
  19.     void Update () {
  20.         if(Input.GetKeyDown(KeyCode.I) && temp == false)
  21.         {
  22.             HUD.GetComponent<Canvas>().enabled = true;
  23.             Inventory.GetComponent<Canvas>().enabled = false;
  24.         }
  25.         if(Input.GetKeyDown(KeyCode.I))
  26.         {
  27.             Inventory.GetComponent<Canvas>().enabled = !Inventory.GetComponent<Canvas>().enabled;
  28.             temp = true;
  29.         }
  30.     }
  31.     void EnableInventory()
  32.     {
  33.        
  34.         HUD.GetComponent<Canvas>().enabled = false;
  35.         Inventory.GetComponent<Canvas>().enabled = true;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement