I have started a coding to enable or disable a camera when the M key is pressed, But I have run into a issue, when the M key is pressed nothing happens, I have looked in the inspector and the “mode” value isn’t changing.
code as follows:
using UnityEngine;
using System.Collections;
public class MainMap : MonoBehaviour {
public int mode = 1;
public GameObject MapCam;
// Update is called once per frame
void Update () {
if(Input.GetKeyDown(KeyCode.M)) {
if (mode == 1) {
mode = mode - 1;
MapCam.SetActive (true);
}
if (mode == 0) {
mode = mode + 1;
MapCam.SetActive (false);
}
}
}
}