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("__touchrecv__");
|
||||
receiver.AddComponent<UnityPointerReceiver>().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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,11 +61,11 @@ namespace Cryville.Common.Unity.Input {
|
||||
pos.y = Screen.height - pos.y;
|
||||
var vec = new InputVector(time, pos);
|
||||
if (t.phase == TouchPhase.Began || t.phase == TouchPhase.Stationary || t.phase == TouchPhase.Moved) {
|
||||
handler.OnInput(0, t.fingerId, vec);
|
||||
handler.Feed(0, t.fingerId, vec);
|
||||
}
|
||||
else if (t.phase == TouchPhase.Ended || t.phase == TouchPhase.Canceled) {
|
||||
handler.OnInput(0, t.fingerId, vec);
|
||||
handler.OnInput(0, t.fingerId, new InputVector(time));
|
||||
handler.Feed(0, t.fingerId, vec);
|
||||
handler.Feed(0, t.fingerId, new InputVector(time));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user