I'm trying to create a pointer using a NGUI sprite. What I want to achieve is to have a sprite that points towards the direction of an object by moving along the screen borders (the object it points is outside the screen on a 3d plane).
The problem I have is that I don't know how to convert the intersection points on screen with my NGUI camera viewport position. I have 2 cameras, one looking down a 3D world and one used for NGUI. I can calculate the point along the screen borders for the main camera, but I don't know how to convert the world position to the NGUI UICamera where all my GUI stuff is (including my pointer sprite).
Here is an example of how I calculate the intersection point between the left border of the screen and the line from the middle of the screen and the target position (I then check if there's an intersection with other borders of the screen if none is found with the left border):
Vector2 intersection = new Vector2();
Vector2 topLeft = new Vector2(MainController.instance.visibleArea.TOP_LEFT.x, MainController.instance.visibleArea.TOP_LEFT.z);
Vector2 bottomLeft = new Vector2(MainController.instance.visibleArea.BOTTOM_LEFT.x, MainController.instance.visibleArea.BOTTOM_LEFT.z);
Vector2 topRight = new Vector2(MainController.instance.visibleArea.TOP_RIGHT.x, MainController.instance.visibleArea.TOP_RIGHT.z);
Vector2 bottomRight = new Vector2(MainController.instance.visibleArea.BOTTOM_RIGHT.x, MainController.instance.visibleArea.BOTTOM_RIGHT.z);
Vector2 targetPos = new Vector2(target.x, target.z);
Vector2 screenCenter = MainController.instance.screenCenter;
//Debug.LogWarning("SCREEN CENTER: "+screenCenter.x+", "+screenCenter.y);
//left border
if(Utils.LineIntersection(topLeft, bottomLeft, targetPos, screenCenter, ref intersection)){
//TODO: convert intersection point to NGUI camera screen position
Thanks