Search Unity

Unity 2018.3.02f GPS - bug [tells me gps is not enabled by user, but it is enabled]

Discussion in 'Android' started by genaray, Dec 30, 2018.

  1. genaray

    genaray

    Joined:
    Feb 8, 2017
    Posts:
    191
    Well... Unity 2018.3.02f seems really buggy so far... i updated my GPS based app from Unity 2017 LTS to the 2018.3.02f version and even if my GPS is enabled by the user, it tells me that it isnt enabled... heres my code so far...Does anyone know why that may happen ? Im using a Honor 10 with android 8.1.0..

    i hope that even some of the moderators could finally take a look at those forums to help the community.

    Code (CSharp):
    1. public class GPSLocation : MonoBehaviour{
    2.  
    3.     public static GPSLocation instance;
    4.  
    5.     public UnityEvent gpsNotEnabled;
    6.  
    7.     public void Start() {
    8.  
    9.         instance = this;
    10.  
    11.         StartCoroutine(locate());
    12.  
    13.     }
    14.  
    15.     public IEnumerator locate(){
    16.  
    17.         // THIS IS TRIGGERED EVEN IF IT IS ENABLED !!!!!!!
    18.         // First, check if user has location service enabled
    19.         if (!Input.location.isEnabledByUser){
    20.  
    21.             Debug.Log("<GPSLocation : GPS not enabled by user>");
    22.             gpsNotEnabled.Invoke();
    23.  
    24.             yield break;
    25.         }
    26.  
    27.         // Start service before querying location
    28.         Input.location.Start();
    29.  
    30.         // Wait until service initializes
    31.         int maxWait = 20;
    32.         while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
    33.         {
    34.             yield return new WaitForSeconds(1);
    35.             maxWait--;
    36.         }
    37.  
    38.         // Service didn't initialize in 20 seconds
    39.         if (maxWait < 1)
    40.         {
    41.             Debug.Log("<GPSLocation : Timed out>");
    42.             yield break;
    43.         }
    44.  
    45.         // Connection has failed
    46.         if (Input.location.status == LocationServiceStatus.Failed)
    47.         {
    48.             Debug.Log("<GPSLocation : Unable to determine device location>");
    49.             yield break;
    50.         }
    51.         else
    52.         {
    53.             // Access granted and location value could be retrieved
    54.             Debug.Log("<GPSLocation : Location: " + (float)Input.location.lastData.latitude + " " + (float)Input.location.lastData.longitude +">");
    55.             Debug.Log("<GPSLocation : Location: " + Input.location.lastData.latitude.ToString() + " " + Input.location.lastData.longitude.ToString() + " " + Input.location.lastData.altitude + " " + Input.location.lastData.horizontalAccuracy + " " + Input.location.lastData.timestamp+">");
    56.         }
    57.  
    58.         // Stop service if there is no need to query location updates continuously
    59.         Input.location.Stop();
    60.     }
    61. }
    62.  
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    Have you submitted bug-reports for the issues you came across? Otherwise it probably stays buggy.

    If you have a project where this issue reproduces, please submit a bug-report as described in this document:
    https://unity3d.com/unity/qa/bug-reporting

    After you submitted the bug-report, you receive a confirmation email with a bug-report Case number. You can post this Case number here (in this forum thread) for Unity staff to pick up, in case they see it.
     
  3. genaray

    genaray

    Joined:
    Feb 8, 2017
    Posts:
    191
    Theres one problem... still using windows 7 and once i try to report that bug its stuck on "Collecting for report"... it showed me the message one hour long, till i decided to try it again... second time didnt worked too... well...
     
  4. Harald_Heide

    Harald_Heide

    Joined:
    Jul 22, 2015
    Posts:
    81
    Have you filed a bug report not being able to file a bug report? But seriously, me seems to have same problem but running windows 10
     
  5. Harald_Heide

    Harald_Heide

    Joined:
    Jul 22, 2015
    Posts:
    81
    Same prob on 2018.3.4 with Samsung galaxy 8 and also Huawei mate pro 20 or whatever itS named