hi i just figured out some differences between Code (csharp): Camera.mainCamera and Code (csharp): GameObject.Find("Main Camera").camera Both commands return the same camera object. So what i want to do is calculate the position of an world object outside the screen bounds to indicate an arrow on the screen. The arrow points to that world object. Now i have two cameras in my scene. One main camera and one gui camera. For my calculations i have to find the main camera. When using Camera.mainCamera i get the gui camera so i saved my main camera into a field: Code (csharp): public void Start() { mainCamera = GameObject.Find("Main Camera").camera; } The point is that the calculation with the field mainCamera works different from using Camera.mainCamera when switching off the gui cam. Although mainCamera and Camera.mainCamera return the same camera object. Does anyone know about that issue? Is it a bug or is it purposed?
here are some further code snippets for a better understanding: Code (csharp): if (!IsInScreenBounds(transform.position) state == ScreenState.inScreen) { state = ScreenState.outOfScreen; directionArrow = (GameObject)Instantiate(directionArrowPrefab, Vector3.zero, Quaternion.identity); MessageRouter.Instance.ShowDirectionArrow(gameObject, directionArrow } listener: Code (csharp): private void OnShowDirectionArrow(GameObject source, GameObject arrow) { arrow.transform.parent = transform; DirectionArrow directionArrowComponent = (DirectionArrow)arrow.GetComponent(typeof(DirectionArrow)); directionArrowComponent.target = source; } the calculation of the arrows position: Code (csharp): private void UpdatePosition() { targetScreenPosition = Camera.mainCamera.WorldToScreenPoint(target.transform.position); targetScreenPositionFromCenter = screenCenter - targetScreenPosition; ...