This is my first post on Stack Exchange.

I have exhausted my research through the game engine forums, so I am trying this forum since you guys seem to be the experts.

I have an external device that is feeding in UTM grid coordinates into the computer and using Unity 3d Game Engine: www.unity3d.com. This is a VR type project.

Im using C# and Javascript, those are the two accepted languages in Unity. I have found this code for C# online and have tried working it to my project but there seems to be some conversion into the engine errors that im struggling with. Here is the code I found, is this something I can use or will it not work in this context?

Basically I want to plug in my UTM coordinates and spit out Lat/ Long.

Hopefully it is that simple to setup and I have provided enough information about my project.

```
public class NewBehaviourScript : MonoBehaviour {
public double utmEast; //The updated UTM Easting
public double utmNorth; //The updated UTM Northing
public string utmZone; // The updated UTM Zone user is currently in.
public static void ToLatLon(double utmX, double utmY, string utmZone, out double latitude, out double longitude)
{
bool isNorthHemisphere = utmZone.Last() >= 'N';
var diflat = -0.00066286966871111111111111111111111111;
var diflon = -0.0003868060578;
var zone = int.Parse(utmZone.Remove(utmZone.Length - 1));
var c_sa = 6378137.000000;
var c_sb = 6356752.314245;
var e2 = Math.Pow((Math.Pow(c_sa, 2) - Math.Pow(c_sb, 2)), 0.5) / c_sb;
var e2cuadrada = Math.Pow(e2, 2);
var c = Math.Pow(c_sa, 2) / c_sb;
var x = utmX - 500000;
var y = isNorthHemisphere ? utmY : utmY - 10000000;
var s = ((zone * 6.0) - 183.0);
var lat = y / (c_sa * 0.9996);
var v = (c / Math.Pow(1 + (e2cuadrada * Math.Pow(Math.Cos(lat), 2)), 0.5)) * 0.9996;
var a = x / v;
var a1 = Math.Sin(2 * lat);
var a2 = a1 * Math.Pow((Math.Cos(lat)), 2);
var j2 = lat + (a1 / 2.0);
var j4 = ((3 * j2) + a2) / 4.0;
var j6 = ((5 * j4) + Math.Pow(a2 * (Math.Cos(lat)), 2)) / 3.0;
var alfa = (3.0 / 4.0) * e2cuadrada;
var beta = (5.0 / 3.0) * Math.Pow(alfa, 2);
var gama = (35.0 / 27.0) * Math.Pow(alfa, 3);
var bm = 0.9996 * c * (lat - alfa * j2 + beta * j4 - gama * j6);
var b = (y - bm) / v;
var epsi = ((e2cuadrada * Math.Pow(a, 2)) / 2.0) * Math.Pow((Math.Cos(lat)), 2);
var eps = a * (1 - (epsi / 3.0));
var nab = (b * (1 - epsi)) + lat;
var senoheps = (Math.Exp(eps) - Math.Exp(-eps)) / 2.0;
var delt = Math.Atan(senoheps / (Math.Cos(nab)));
var tao = Math.Atan(Math.Cos(delt) * Math.Tan(nab));
longitude = ((delt * (180.0 / Math.PI)) + s) + diflon;
latitude = ((lat + (1 + e2cuadrada * Math.Pow(Math.Cos(lat), 2) - (3.0 / 2.0) * e2cuadrada * Math.Sin(lat) * Math.Cos(lat) * (tao - lat)) * (tao - lat)) * (180.0 / Math.PI)) + diflat;
print(latitude);// Looking to display in the Console Log Lat.
print(longitude);// Looking to display in the Console Log Long.
}
}
```