private void PositionScannable(IScannable scannable) {
// Find the game object's screen position:
Vector2 screenPos = Camera.main.WorldToScreenPoint(scannable.GameObject.transform.position);
// Get the Camera rendering the overlay layer:
Camera cam = NGUITools.FindCameraForLayer(gameObject.layer);
// Translate the screen pos into the coordinates for the NGUI camera:
Vector3 adjustedPos = cam.ScreenToWorldPoint(screenPos);
scannable.ScannerInstance.transform.position = adjustedPos;
// At this point, if nothing else is done, the ScannerInstance follows the target, but can leave the area of the
// this widget, which I don't want.
// Tried a number of variations of the following:
/*
Bounds contentBounds = NGUIMath.CalculateRelativeWidgetBounds(transform, scannable.ScannerInstance.transform);
Vector2 scanMin = new Vector2(contentBounds.min.x, contentBounds.min.y);
Vector2 scanMax = new Vector2(contentBounds.max.x, contentBounds.max.y);
Bounds areaBounds = NGUIMath.CalculateRelativeWidgetBounds(transform);
Vector2 areaMin = new Vector2(areaBounds.min.x, areaBounds.min.y);
Vector2 areaMax = new Vector2(areaBounds.max.x, areaBounds.max.y);
Vector2 offset = NGUIMath.ConstrainRect(scanMin,scanMax,areaMin,areaMax);
Vector3 constrained = scannable.ScannerInstance.transform.position;
constrained.x += offset.x;
constrained.y += offset.y;
scannable.ScannerInstance.transform.position = cam.ScreenToViewportPoint(constrained);
*/
}