Skip to content

Instantly share code, notes, and snippets.

@Matheus-de-Souza
Created November 29, 2012 02:42
Show Gist options
  • Save Matheus-de-Souza/4166431 to your computer and use it in GitHub Desktop.
Save Matheus-de-Souza/4166431 to your computer and use it in GitHub Desktop.
Vector3 mousePosition = MouseUtils.ConvertMousePositionToWorldPosition(Input.mousePosition,
ScenarioData.MinPointToView,
ScenarioData.MaxPointToView);
public class MouseUtils {
public static Vector3 ConvertMousePositionToWorldPosition(Vector3 mousePosition,
Vector3 minPoint,
Vector3 maxPoint)
{
mousePosition.x = ((mousePosition.x / (float)Screen.width) * (maxPoint.x - minPoint.x)) + minPoint.x;
mousePosition.y = ((mousePosition.y / (float)Screen.height) * (maxPoint.y - minPoint.y)) + minPoint.y;
return mousePosition;
}
}
public class ScenarioData
{
public static Vector3 MaxPointToView = new Vector3( 14f, 14f, 0.1f);
public static Vector3 MinPointToView = new Vector3(-14f, -1f, -0.1f);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment