void Awake()
    {
        toggle      = GetComponent <Toggle>();
        toggle.isOn = false;
        switch (sourceType)
        {
        case SourceType.fake:
            //locationProvider = new FakeLocationSource();
            break;

        case SourceType.gps:
            locationProvider = new GpsLocationSource();
            break;

                        #if INDOORGUIDE
        case SourceType.nimble:
            locationProvider = new NimbleLocationSource();
            break;
                        #endif
        default:
            //locationProvider = new FakeLocationSource();
            break;
        }
        toggle.onValueChanged.AddListener(enabled =>
        {
            if (enabled)
            {
                LocationSourceManager.AddProvider(locationProvider);
            }
            else
            {
                LocationSourceManager.RemoveProvider(locationProvider);
            }
        });
    }
 void Awake()
 {
     button = GetComponent <Button>();
     button.onClick.AddListener(() =>
     {
         if (LocationSourceManager.IsRunning)
         {
             LocationSourceManager.StopLocationUpdates();
         }
         else
         {
             LocationSourceManager.StartLocationUpdates();
         }
     });
 }
Example #3
0
    void Awake()
    {
        dropDown = GetComponent <Dropdown>();
        dropDown.options.Clear();
        dropDown.options.Add(new Dropdown.OptionData("Disabled"));
        dropDown.options.Add(new Dropdown.OptionData("Fake"));
        if (enableGPS)
        {
            dropDown.options.Add(new Dropdown.OptionData("GPS"));
        }
#if UNITY_IOS
        if (enableNimble)
        {
            dropDown.options.Add(new Dropdown.OptionData("Nimble"));
        }
#endif
        dropDown.captionText.text = dropDown.options.First().text;

        dropDown.onValueChanged.AddListener(selection =>
        {
            LocationSourceManager.RemoveAllProvidersAndStop();
            string selectedOption = dropDown.options[selection].text;
            if (selectedOption == "Fake")
            {
                fakeLocation = AR.Geolocation.LocationSourceManager.CurrentGeolocation;
                LocationSourceManager.AddProvider(new FakeLocationSource(fakeLocation));
            }
            else if (selectedOption == "GPS")
            {
                LocationSourceManager.AddProvider(new GpsLocationSource());
            }
                        #if INDOORGUIDE
            else if (selectedOption == "Nimble")
            {
                LocationSourceManager.AddProvider(new NimbleLocationSource());
            }
                        #endif
            LocationSourceManager.StartLocationUpdates();
        });
    }