Pixel To World Unit Conversion
using UnityEngine ; using System.Collections ; public class ResolutionCompensation : MonoBehavior { public Vector2 WorldUnitsInCamera ; public Vector2 WorldToPixelAmount ; public GameObject Camera ; void Awake ( ) { //Finding Pixel To World Unit Conversion Based On Orthographic Size Of Camera WorldUnitsInCamera . y = Camera . GetComponent < Camera > ( ) . orthographicSize * 2 ; WorldUnitsInCamera . x = WorldUnitsInCamera . y * Screen . width / Screen . height ; WorldToPixelAmount . x = Screen . width / WorldUnitsInCamera . x ; WorldToPixelAmount . y = Screen . height / WorldUnitsInCamera . y ; } //Taking Your Camera Location And Is Off Setting For Position And For Amount Of World Units In Camera public Vector2 ConvertToWorldUnits ( Vector2 TouchLocation ) { Vector2 returnVec2 ; returnVec2 . x = ( ( TouchLocation . x / WorldToPixelAmount . x ) - ( WorldUnitsInCamera