我正在爲Android製作汽車遊戲,並且我創建了節氣門,休息和方向盤。GUI.DrawTexture和GUITexture多點觸控
所有工作都很好,但當我接觸油門或剎車時,我不能使用方向盤。 或者當我使用方向盤時,如果我碰到油門或斷開,方向盤有點搞亂。
油門和突破都GUITexture
, 方向盤使用GUI.DrawTexture
(因爲GUITexture不支持旋轉)
我檢查這樣的接觸:
int touchCount = Input.touchCount;
for (int i = 0; i < touchCount; ++i){
Touch t = Input.GetTouch(i);
if (t.phase != TouchPhase.Ended &&
this.throttleButton.texture.HitTest(t.position)){
throttle = 1f;
}
if (t.phase != TouchPhase.Ended &&
this.brakeButton.texture.HitTest(t.position)){
brake = 1f;
}
//inputGuiPosition variable was used because Unity3d GUI system is a little opposite
Vector3 inputGuiPosition = t.position;
inputGuiPosition.y = Screen.height - inputGuiPosition.y;
if (t.phase == TouchPhase.Began &&
wheelRect.Contains((inputGuiPosition))){
steerInput = SteeringWheel.GetAngle() * (-1f/270f);
}
}