49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
using CHN;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class UIActiveManager : MonoBehaviour
|
|
{
|
|
private UserInputManager userInputManager;
|
|
private Canvas_Popup canvasPopup;
|
|
private Canvas_Top canvasTop;
|
|
private MachineKPIManager machineKPIManager;
|
|
|
|
private InputHandler inputHandler;
|
|
|
|
public bool isUIActive;
|
|
|
|
public override void AfterAwake()
|
|
{
|
|
userInputManager = FindSingle<UserInputManager>();
|
|
canvasPopup = FindSingle<Canvas_Popup>();
|
|
canvasTop = FindSingle<Canvas_Top>();
|
|
machineKPIManager = FindSingle<MachineKPIManager>();
|
|
|
|
inputHandler = GetInputHandler();
|
|
userInputManager.SetHandler(inputHandler);
|
|
|
|
isUIActive = true;
|
|
}
|
|
private InputHandler GetInputHandler()
|
|
{
|
|
var getKeyActions = new Dictionary<KeyCode, Action>();
|
|
var downKeyActions = new Dictionary<KeyCode, Action>();
|
|
var upKeyActions = new Dictionary<KeyCode, Action>();
|
|
|
|
downKeyActions.Add(KeyCode.F5, ActiveCanvas);
|
|
|
|
var handler = new InputHandler(null, downKeyActions, null, null);
|
|
return handler;
|
|
}
|
|
private void ActiveCanvas()
|
|
{
|
|
isUIActive = !isUIActive;
|
|
|
|
canvasPopup.SetActive(isUIActive);
|
|
canvasTop.SetActive(isUIActive);
|
|
machineKPIManager.gameObject.SetActive(isUIActive);
|
|
}
|
|
}
|