using UnityEngine;
using System.Collections;
using UnityStandardAssets.Characters.FirstPerson;
public class InputEnabler : MonoBehaviour {
static FirstPersonController FPSChar;
// Use this for initialization
void Start ()
{
FPSChar = GameObject.FindObjectOfType();
Disable();
}
public static void Disable() // disabling cursor and enabling movement
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
FPSChar.enabled = true;
}
public static void Enable() // enabling cursor and movement
{
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
FPSChar.enabled = false;
}
}
using UnityEngine;
using System.Collections;
public class Inventory : MonoBehaviour {
public GameObject inventory;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
if(inventory.activeSelf)
{
if(Input.GetKeyDown(KeyCode.I))
//Disable Inventory
inventory.SetActive(false);
InputEnabler.Disable();
}
else
{
if(Input.GetKeyDown(KeyCode.I))
{
//Emable Inventory
inventory.SetActive(true);
InputEnabler.Enable();
}
}
}
}
↧