using System.Collections.Generic; namespace Superlazy.UI { public class SLUIInputControl : SLUIComponent { private static Dictionary inputControls = new Dictionary(); private string inputKey; public static void InputKeyControl(string key) { if (inputControls.ContainsKey(key)) { var value = inputControls[key]; var buttons = value.GetComponentsInChildren(); foreach (var button in buttons) { if (button.gameObject.activeInHierarchy && (button.comparison.useCheckValue == false || button.comparison.Result)) { button.ButtonAction(); break; } } var dragButtons = value.GetComponentsInChildren(); foreach (var button in dragButtons) { if (button.gameObject.activeInHierarchy && (button.comparison.useCheckValue == false || button.comparison.Result)) { button.ButtonAction(); break; } } var longPresseds = value.GetComponentsInChildren(); foreach (var longPressed in longPresseds) { if (longPressed.gameObject.activeInHierarchy) { longPressed.OnPointerDown(null); } } } } public static void ReleaseKeyControl(string key) { if (inputControls.ContainsKey(key)) { var value = inputControls[key]; var longPresseds = value.GetComponentsInChildren(); foreach (var longPressed in longPresseds) { if (longPressed.gameObject.activeInHierarchy) { longPressed.OnPointerUp(null); } } } } protected override void Validate() { } protected override void Init() { } protected override void Enable() { var root = SLGame.SessionGet(bindParent.BindPath); if (root["InputKey"]) { if (inputControls.ContainsKey(root["InputKey"])) { SLLog.Warn($"{root["InputKey"]} already add"); } else { inputKey = root["InputKey"]; inputControls.Add(root["InputKey"], this); } } } protected override void Disable() { if (string.IsNullOrEmpty(inputKey) == false) { inputControls.Remove(inputKey); inputKey = ""; } } private void OnChange() { if (bindParent.Active == false) return; var sessionRoot = SLGame.SessionGet(bindParent.BindPath); if (sessionRoot == false) return; // TEMP: 세션루트가 삭제되었지만, 삭제되되기전 코루틴 처리가 있을 수 있음 if (sessionRoot["InputKey"] != inputKey) { inputControls.Remove(inputKey); inputKey = sessionRoot["InputKey"]; inputControls.Add(sessionRoot["InputKey"], this); } } } }