F5 누를 때 UI 활성화/비활성화 되도록 단축키 추가
This commit is contained in:
@@ -8895,6 +8895,8 @@ Transform:
|
||||
- {fileID: 835498836}
|
||||
- {fileID: 548894194}
|
||||
- {fileID: 1431561627}
|
||||
- {fileID: 448759809}
|
||||
- {fileID: 491017562}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &49804084
|
||||
@@ -88880,6 +88882,51 @@ Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 3571782791591332055, guid: b6fb23e8e8140a74ea7cd160312cd108, type: 3}
|
||||
m_PrefabInstance: {fileID: 448459224}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &448759808
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 448759809}
|
||||
- component: {fileID: 448759810}
|
||||
m_Layer: 0
|
||||
m_Name: UIActiveManager
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &448759809
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 448759808}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 49225333}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &448759810
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 448759808}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2644676b5cc9dad4bb2a49553b36966f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
isUIActive: 0
|
||||
--- !u!1 &449177296
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -96896,6 +96943,50 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 490951029}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &491017561
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 491017562}
|
||||
- component: {fileID: 491017563}
|
||||
m_Layer: 0
|
||||
m_Name: UserInputManager
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &491017562
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 491017561}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 49225333}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &491017563
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 491017561}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6b37771737b0e1c45aa27bf9a659ee88, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1001 &491119051
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -216418,7 +216509,6 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: c73a0fd10aec4bd4c8d1e061588fb531, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Dropdown_WorkOrderNumber: {fileID: 0}
|
||||
mainChart: {fileID: 0}
|
||||
subCharts: []
|
||||
data:
|
||||
@@ -306247,7 +306337,6 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_AlphaFadeSpeed: 0.15
|
||||
hideItemName:
|
||||
deinteractableItems: []
|
||||
--- !u!1001 &1379640318
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -439818,7 +439907,6 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_AlphaFadeSpeed: 0.15
|
||||
hideItemName:
|
||||
deinteractableItems: []
|
||||
--- !u!1 &2030846025
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
41
Assets/Scripts/InputHandler.cs
Normal file
41
Assets/Scripts/InputHandler.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CHN
|
||||
{
|
||||
public class InputHandler
|
||||
{
|
||||
public Action updateLoop;
|
||||
public Dictionary<KeyCode, Action> getKeyActions;
|
||||
public Dictionary<KeyCode, Action> downKeyActions;
|
||||
public Dictionary<KeyCode, Action> upKeyActions;
|
||||
public Dictionary<KeyCode, Dictionary<KeyCode, Action>> shortCutActions;
|
||||
public InputHandler(
|
||||
Dictionary<KeyCode, Action> getKeyActions = null,
|
||||
Dictionary<KeyCode, Action> downKeyActions = null,
|
||||
Dictionary<KeyCode, Action> upKeyActions = null,
|
||||
Dictionary<KeyCode, Dictionary<KeyCode, Action>> shortCutActions = null,
|
||||
Action updateLoop = null)
|
||||
{
|
||||
if (getKeyActions == null)
|
||||
getKeyActions = new();
|
||||
|
||||
this.getKeyActions = getKeyActions;
|
||||
|
||||
if (downKeyActions == null)
|
||||
downKeyActions = new();
|
||||
this.downKeyActions = downKeyActions;
|
||||
|
||||
if(upKeyActions == null)
|
||||
upKeyActions = new();
|
||||
this.upKeyActions = upKeyActions;
|
||||
|
||||
if(shortCutActions == null)
|
||||
shortCutActions = new();
|
||||
this.shortCutActions = shortCutActions;
|
||||
|
||||
this.updateLoop=updateLoop;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/InputHandler.cs.meta
Normal file
2
Assets/Scripts/InputHandler.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09ab8417641a6d940a456699f4a25af1
|
||||
48
Assets/Scripts/UIActiveManager.cs
Normal file
48
Assets/Scripts/UIActiveManager.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UIActiveManager.cs.meta
Normal file
2
Assets/Scripts/UIActiveManager.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2644676b5cc9dad4bb2a49553b36966f
|
||||
168
Assets/Scripts/UserInputManager.cs
Normal file
168
Assets/Scripts/UserInputManager.cs
Normal file
@@ -0,0 +1,168 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using WI;
|
||||
|
||||
namespace CHN
|
||||
{
|
||||
public class UserInputManager : MonoBehaviour, ISingle
|
||||
{
|
||||
Dictionary<KeyCode, Action> getKeyActionTable = new Dictionary<KeyCode, Action>();
|
||||
Dictionary<KeyCode, Action> upKeyActionTable = new Dictionary<KeyCode, Action>();
|
||||
Dictionary<KeyCode, Action> downKeyActionTable = new Dictionary<KeyCode, Action>();
|
||||
Dictionary<KeyCode, Dictionary<KeyCode, Action>> shortCutActionTable = new ();
|
||||
Stack<InputHandler> handlerStack = new();
|
||||
Action updateLoop;
|
||||
|
||||
public void SetHandler(InputHandler handler)
|
||||
{
|
||||
SetKeyboardPreset(handler);
|
||||
}
|
||||
|
||||
public void RemoveHandler(InputHandler handler)
|
||||
{
|
||||
Stack<InputHandler> tempStack = new();
|
||||
|
||||
while (handlerStack.Count > 0)
|
||||
{
|
||||
var currentHandler = handlerStack.Pop();
|
||||
if (currentHandler == handler)
|
||||
{
|
||||
RemoveKeyActionPreset(currentHandler);
|
||||
break;
|
||||
}
|
||||
|
||||
tempStack.Push(currentHandler);
|
||||
}
|
||||
|
||||
while(tempStack.Count > 0)
|
||||
{
|
||||
var tempHandler = tempStack.Pop();
|
||||
SetKeyboardPreset(tempHandler);
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveKeyActionPreset(InputHandler handler)
|
||||
{
|
||||
foreach(var k in handler.getKeyActions)
|
||||
{
|
||||
getKeyActionTable.Remove(k.Key);
|
||||
}
|
||||
|
||||
foreach(var k in handler.upKeyActions)
|
||||
{
|
||||
upKeyActionTable.Remove(k.Key);
|
||||
}
|
||||
|
||||
foreach(var k in handler.downKeyActions)
|
||||
{
|
||||
downKeyActionTable.Remove(k.Key);
|
||||
}
|
||||
|
||||
foreach(var k in handler.shortCutActions)
|
||||
{
|
||||
foreach(var kk in k.Value)
|
||||
{
|
||||
shortCutActionTable[k.Key].Remove(kk.Key);
|
||||
}
|
||||
}
|
||||
updateLoop -= handler.updateLoop;
|
||||
}
|
||||
void SetKeyboardPreset(InputHandler handler)
|
||||
{
|
||||
handlerStack.Push(handler);
|
||||
foreach (var k in handler.getKeyActions)
|
||||
{
|
||||
getKeyActionTable[k.Key] = k.Value;
|
||||
}
|
||||
|
||||
foreach(var k in handler.upKeyActions)
|
||||
{
|
||||
upKeyActionTable[k.Key]= k.Value;
|
||||
}
|
||||
|
||||
foreach(var k in handler.downKeyActions)
|
||||
{
|
||||
downKeyActionTable[k.Key]= k.Value;
|
||||
}
|
||||
|
||||
foreach (var k in handler.shortCutActions)
|
||||
{
|
||||
if (!shortCutActionTable.ContainsKey(k.Key))
|
||||
{
|
||||
shortCutActionTable.Add(k.Key, new Dictionary<KeyCode, Action>());
|
||||
}
|
||||
|
||||
foreach (var kk in k.Value)
|
||||
{
|
||||
if (shortCutActionTable[k.Key].ContainsKey(kk.Key))
|
||||
shortCutActionTable[k.Key].Remove(kk.Key);
|
||||
|
||||
shortCutActionTable[k.Key].Add(kk.Key, kk.Value);
|
||||
}
|
||||
}
|
||||
updateLoop += handler.updateLoop;
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
if (IsEditInputField())
|
||||
return;
|
||||
|
||||
foreach (var key in downKeyActionTable.Keys)
|
||||
{
|
||||
if (Input.GetKeyDown(key))
|
||||
{
|
||||
downKeyActionTable[key]?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var key in getKeyActionTable.Keys)
|
||||
{
|
||||
if (Input.GetKey(key))
|
||||
{
|
||||
getKeyActionTable[key]?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var key in upKeyActionTable.Keys)
|
||||
{
|
||||
if (Input.GetKeyUp(key))
|
||||
{
|
||||
upKeyActionTable[key]?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var key in shortCutActionTable.Keys)
|
||||
{
|
||||
if (Input.GetKey(key))
|
||||
{
|
||||
if (shortCutActionTable.TryGetValue(key, out var kk))
|
||||
{
|
||||
foreach (var k in kk)
|
||||
{
|
||||
if (Input.GetKeyDown(k.Key))
|
||||
{
|
||||
k.Value?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateLoop?.Invoke();
|
||||
}
|
||||
|
||||
bool IsEditInputField()
|
||||
{
|
||||
GameObject selectedObj = EventSystem.current.currentSelectedGameObject;
|
||||
|
||||
if (selectedObj == null)
|
||||
return false;
|
||||
|
||||
return selectedObj.GetComponent<TMP_InputField>() != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UserInputManager.cs.meta
Normal file
2
Assets/Scripts/UserInputManager.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b37771737b0e1c45aa27bf9a659ee88
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user