Unity3d GUI.DrawTexture和GuitTexture多点触控
我正在为android做一个汽车游戏,我创建了油门、刹车和方向盘 一切正常,但当我触碰油门或刹车时,我不能使用方向盘。 或者当我使用方向盘时,如果我触碰油门或刹车,方向盘有点乱 节气门和制动为吉他结构, 方向盘正在使用Unity3d GUI.DrawTexture和GuitTexture多点触控,unity3d,Unity3d,我正在为android做一个汽车游戏,我创建了油门、刹车和方向盘 一切正常,但当我触碰油门或刹车时,我不能使用方向盘。 或者当我使用方向盘时,如果我触碰油门或刹车,方向盘有点乱 节气门和制动为吉他结构, 方向盘正在使用GUI.DrawTexture(因为GuitTexture不支持旋转) 我正在检查这样的触摸: int touchCount = Input.touchCount; for (int i = 0; i < touchCount; ++i){
GUI.DrawTexture
(因为GuitTexture不支持旋转)
我正在检查这样的触摸:
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);
}
}
int touchCount=Input.touchCount;
对于(int i=0;i
这是因为Unity的GUI不支持多点触摸。如果您想在unity游戏中使用多点触控,您需要unity的资产存储中的一些输入触控资产。我很确定OnGUI无法处理多点触控。您应该看看如何使用touch API: