void Awake() { if (instance == null) { instance = this; } isCrash = true; setCameraX(); }
//GPS initialization IEnumerator Start() { player = this.GetComponent<Player>(); ufo = GameObject.Find("UFO").GetComponent<UfoScript>(); int wait = maxWait; if (!Input.location.isEnabledByUser){ output = "No GPS, or not activated."; yield return false; } //start gps Input.location.Start(5f,5f); //wait for initialization while (Input.location.status == LocationServiceStatus.Initializing && wait > 0) { output = "Initializing GPS. MaxWait: "+wait; yield return new WaitForSeconds(1); wait--; } if (wait < 1) { output = "Timeout :("; yield return false; } if (Input.location.status == LocationServiceStatus.Failed) { output = "Unable to determine device location :("; yield return false; } //try to retrieve first lat/lon coordinates wait = maxWait; while( (gpsOrigin.x == 0 || gpsOrigin.y == 0) && wait > 0){ output = "Get origin: MaxWait: "+wait; resetPosition(); yield return new WaitForSeconds(1); wait--; } if (wait < 1) { output = "Timeout :("; yield return false; } //initialization complete isReady = true; }