Hi guys, i have ecountered an issue with pixelRect when i tried to script my minimap. Everything is working just fine except when i run game pixel rect isn’t where it should (i think be), i mean pixelRect of the “thisCamra” is always in left bottm corner of the screen.
Here is the code:
public Camera thisCamera;
public Camera mainCamera;
void Start () {
thisCamera = GetComponent<Camera> ();
}
void Update () {
if (thisCamera.pixelRect.Contains (Input.mousePosition)) {
if(Input.GetKey (KeyCode.Mouse0)) {
Ray MouseRay = thisCamera.ScreenPointToRay (Input.mousePosition);
RaycastHit hitInfo;
Vector3 newPosition = MouseRay.origin;
newPosition.y = mainCamera.transform.position.y;
mainCamera.transform.position = newPosition;
}
}
}
Do you have any ideas y i doesnt work and how to fix it?
(there is screen in attachemnt that explains a little more)