Implement input proxy. Change input callback delegate to event. Prevents repeated (de)activation.
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user