Implement input proxy. Change input callback delegate to event. Prevents repeated (de)activation.

This commit is contained in:
2022-11-06 00:50:09 +08:00
parent 7f02b75b29
commit 8f98cb63cb
7 changed files with 119 additions and 111 deletions

View File

@@ -9,19 +9,19 @@ namespace Cryville.Common.Unity.Input {
public UnityKeyHandler() { }
public override void Activate() {
protected override void ActivateImpl() {
receiver = new GameObject("__keyrecv__");
recvcomp = receiver.AddComponent<T>();
recvcomp.SetCallback(OnInput);
recvcomp.SetCallback(Feed);
}
public override void Deactivate() {
protected override void DeactivateImpl() {
if (receiver) GameObject.Destroy(receiver);
}
public override void Dispose(bool disposing) {
if (disposing) {
Deactivate();
DeactivateImpl();
}
}