How do I make LocationService.Start work?

I been looking in the forums post like “How to get GPS coordinates in unity 3d” and they all link to the documentation “Unity - Scripting API: LocationService.Start”, but I can’t make it work :c

The example screen is:

function Start () {
        // First, check if user has location service enabled
        if (!Input.location.isEnabledByUser)
        // Start service before querying location
        Input.location.Start ();
        // Wait until service initializes
        var maxWait : int = 20;
        while (Input.location.status
               == LocationServiceStatus.Initializing && maxWait > 0) {
            yield WaitForSeconds (1);
        // Service didn't initialize in 20 seconds
        if (maxWait < 1) {
            print ("Timed out");
        // Connection has failed
        if (Input.location.status == LocationServiceStatus.Failed) {
            print ("Unable to determine device location");
        // Access granted and location value could be retrieved
        else {
            print ("Location: " + Input.location.lastData.latitude + " " +
                   Input.location.lastData.longitude + " " +
                   Input.location.lastData.altitude + " " +
                   Input.location.lastData.horizontalAccuracy + " " +
        // Stop service if there is no need to query location updates continuously
        Input.location.Stop ();

The error

If some body know how to get get GPS coordinates, it would be really appreciated
Thanks in advance : )

You need to put some info in to the start method.

Input.location.Start (1,0.1);

Use these to check if its enabled by the user in Hardware and its status.

Also, I think you are mixing C# and JS in your script.


#pragma strict
import UnityEngine;
import System.Collections;

public class GPS extends MonoBehaviour

Hi, is there any solution to test GPS coordinate without building.
I think it’s a lost of time needing building to know if the code works or not ?
I’m working on a mac with location services enable and unity editor console still saying Input.location.isEnabledByUser is false…