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