using UnityEngine; using UnityEngine.InputSystem; public class CameraController : MonoBehaviour { #if UNITY_EDITOR public float rayLength = 15f; private RaycastHit hitInfo; private Vector3 hitPoint; private Ray ray; void Update() { Vector2 mousePosition = Mouse.current.position.ReadValue(); ray = Camera.main.ScreenPointToRay(new Vector3(mousePosition.x, mousePosition.y, Camera.main.transform.position.z)); hitPoint = ray.origin + ray.direction * rayLength; UnityEditor.SceneView.RepaintAll(); } void OnDrawGizmos() { Gizmos.color = Color.green; Gizmos.DrawLine(ray.origin, hitPoint); float halfSize = 0.2f; Gizmos.color = Color.red; Gizmos.DrawWireCube(hitPoint, new Vector3(halfSize * 2, halfSize * 2, halfSize * 2)); } #endif private Camera _camera; private void Awake() { _camera = transform.GetComponent(); var size = _camera.orthographicSize; _camera.orthographicSize = size * GlobalConstants.DesignResolutionWidth / GlobalConstants.DesignResolutionHeight * Screen.height / Screen.width; } }