I'll keep this short:
UIKeyNavigation should be comparing direction vectors relative to the camera, instead of world space. Currently the system breaks down if your UI/Camera heirarchy has a non-zero rotation, if your UI is 3D, or if your buttons have different Z-depths (for whatever reason). Here are the necessary changes:
static protected Vector3 GetCenter (GameObject go)
{
UIWidget w = go.GetComponent<UIWidget>();
UICamera cam = UICamera.FindCameraForLayer(go.layer);
Vector3 center = go.transform.position;
if (w != null)
{
Vector3[] corners = w.worldCorners;
center = (corners[0] + corners[2]) * 0.5f;
}
center = cam.cachedCamera.WorldToScreenPoint( center );
center.z = 0;
return center;
}
While I'm at it, a layer mask would be cool to restrict navigation between buttons on different layers. Sometimes we have a map screen and a UI overlay and we don't want to be able to navigate between them freely. This would just involve adding a public LayerMask field, and throwing out targets that aren't in the mask in the Get() loop. Let me know what you think.