using UnityEngine;
using System.Collections;
public class mobile_clicker : MonoBehaviour {
public GameObject[] butts;
void Update()
{
foreach(Touch t in Input.touches)
{
foreach(GameObject b in butts)
{
Rect r = b.guiTexture.GetScreenRect();
if( QuadCollide(r.x,r.y,r.width,r.height,t.position.x,t.position.y) )
{
if(t.phase == TouchPhase.Began)
{
b.gameObject.SendMessage("OnMouseDown", null, SendMessageOptions.DontRequireReceiver);
}
else if(t.phase == TouchPhase.Ended)
{
b.gameObject.SendMessage("OnMouseUp", null, SendMessageOptions.DontRequireReceiver);
}
}
}
}
}
bool QuadCollide(float x,float y,float w,float h,float ix,float iy)
{
if(ix>=x)
{
if(iy>=y)
{
if(ix<=(x+w))
{
if(iy<=(y+h))
{
return true;
}
}
}
}
return false;
}
}
Всё исправил, теперь работает. Даже OnMouseUp!
А нельзя ли получить лист всех GUITexture на сцене?
И ещё: как передавать данные между сценами?