Optimize GC for input config.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using Cryville.Common;
|
using Cryville.Common;
|
||||||
using Cryville.Common.Unity;
|
using Cryville.Common.Unity;
|
||||||
using Cryville.Input;
|
using Cryville.Input;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
@@ -73,15 +74,22 @@ namespace Cryville.Crtr.Config {
|
|||||||
_entries[e.Name].OnProxyChanged(e);
|
_entries[e.Name].OnProxyChanged(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Start() {
|
||||||
|
_d_HandleInputEvent = HandleInputEvent;
|
||||||
|
}
|
||||||
|
|
||||||
readonly List<InputSource?> _recvsrcs = new List<InputSource?>();
|
readonly List<InputSource?> _recvsrcs = new List<InputSource?>();
|
||||||
void Update() {
|
void Update() {
|
||||||
if (m_inputDialog.activeSelf) {
|
if (m_inputDialog.activeSelf) {
|
||||||
_consumer.EnumerateEvents(ev => {
|
_consumer.EnumerateEvents(_d_HandleInputEvent);
|
||||||
AddSourceItem(ev.Identifier.Source);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Action<InputEvent> _d_HandleInputEvent;
|
||||||
|
void HandleInputEvent(InputEvent ev) {
|
||||||
|
AddSourceItem(ev.Identifier.Source);
|
||||||
|
}
|
||||||
|
|
||||||
void AddSourceItem(InputSource? src) {
|
void AddSourceItem(InputSource? src) {
|
||||||
if (_recvsrcs.Contains(src)) return;
|
if (_recvsrcs.Contains(src)) return;
|
||||||
_recvsrcs.Add(src);
|
_recvsrcs.Add(src);
|
||||||
|
|||||||
Reference in New Issue
Block a user