If use the raycasts ,and last frame click a UIwidget , if you click sence and the lasthit will be changed!
So the lasthit is error.
Because the code "if(hits.Length > 1) else if(hits.Length == 1 && IsVisible(ref hits[0]))", the another case not be processed!
// If raycasts should be clipped by panels, we need to find a panel for each hit
if (cam.clipRaycasts)
{
RaycastHit[] hits = Physics.RaycastAll(ray, dist, mask);
if (hits.Length > 1)
{
System.Array.Sort(hits, delegate(RaycastHit r1, RaycastHit r2) { return r1.distance.CompareTo(r2.distance); });
for (int b = 0, bmax = hits.Length; b < bmax; ++b)
{
if (IsVisible(ref hits))
{
hit = hits;
return true;
}
}
}
else if (hits.Length == 1 && IsVisible(ref hits[0]))
{
hit = hits[0];
return true;
}
// another ? How to do?
// If you don't do hit= somevalue, the hit are old. It will make some bu on next frame!
continue;