【发布时间】:2015-06-15 13:56:03
【问题描述】:
我使用OnMouseDown()处理按压,但是无法实现多点触控。
该程序包括在您点击时增加然后减少的对象。如果有一个触摸,一切正常。但是,当您尝试同时单击多个对象时,它就不起作用了。
我正在尝试解决问题,但它不起作用,对象无法缩放,多点触控也不起作用。
代码:
using UnityEngine;
using System.Collections;
public class OnTouch : MonoBehaviour {
public AudioClip crash1;
public AudioClip hat_closed;
public AudioClip hat_open;
public bool c;
public bool c1;
public bool c2;
void OnMouseDown(){
if (this.name == "clash") {
GetComponent<AudioSource>().PlayOneShot(hat_open);
c=true;
}
if (this.name == "clash 1") {
GetComponent<AudioSource>().PlayOneShot(hat_closed);
c1=true;
}
if (this.name == "clash 2") {
GetComponent<AudioSource> ().PlayOneShot (crash1);
c2=true;
}
transform.localScale += new Vector3(0.05f, 0.05f, 0);
}
void Update(){
if (c) {transform.localScale = Vector3.Lerp (this.transform.localScale, new Vector3 (0.2f, 0.2f, 0), Time.deltaTime*10f);}
if (c1) {transform.localScale = Vector3.Lerp (this.transform.localScale, new Vector3 (0.2f, 0.2f, 0), Time.deltaTime*10f);}
if (c2) {transform.localScale = Vector3.Lerp (this.transform.localScale, new Vector3 (0.25f, 0.25f, 0), Time.deltaTime*10f);}
}
}
【问题讨论】:
标签: c# android ios mobile unity3d