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

@@ -12,18 +12,18 @@ namespace Cryville.Common.Unity.Input {
}
}
public override void Activate() {
protected override void ActivateImpl() {
receiver = new GameObject("__mouserecv__");
receiver.AddComponent<UnityMouseReceiver>().SetHandler(this);
}
public override void Deactivate() {
protected override void DeactivateImpl() {
if (receiver) GameObject.Destroy(receiver);
}
public override void Dispose(bool disposing) {
if (disposing) {
Deactivate();
DeactivateImpl();
}
}
@@ -57,7 +57,7 @@ namespace Cryville.Common.Unity.Input {
double time = Time.timeAsDouble;
Vector2 pos = unity::Input.mousePosition;
pos.y = Screen.height - pos.y;
handler.OnInput(0, 0, new InputVector(time, pos));
handler.Feed(0, 0, new InputVector(time, pos));
}
}
}