async void Refresh()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                return;
            }

            try
            {
                updating     = true;
                ErrorMessage = "";
                Simulator.Web.Config.ParseConfigFile();

                DatabaseManager.Init();
                var            csservice = new Simulator.Database.Services.ClientSettingsService();
                ClientSettings cls       = csservice.GetOrMake();
                Config.SimID = cls.simid;
                if (String.IsNullOrEmpty(Config.CloudUrl))
                {
                    ErrorMessage = "Cloud URL not set";
                    return;
                }
                if (String.IsNullOrEmpty(Config.SimID))
                {
                    ErrorMessage = "Simulator not linked";
                    return;
                }

                if (API != null)
                {
                    API.Disconnect();
                }

                API = new CloudAPI(new Uri(Config.CloudUrl), Config.SimID);
                var simInfo = CloudAPI.GetInfo();

                var reader = await API.Connect(simInfo);

                await API.EnsureConnectSuccess();

                var ret = await API.GetLibrary <VehicleDetailData>();

                CloudVehicles = ret.ToList();

                string[] guids = AssetDatabase.FindAssets("t:Prefab", new[] { "Assets/External/Vehicles" });
                LocalVehicles = guids.Select(g => AssetDatabase.GUIDToAssetPath(g)).ToList();

                string idOrPath = null;
                if (DeveloperSimulation.Vehicles != null) // get previously selected thing
                {
                    // we abuse VehicleData.Id to store the prefab path
                    idOrPath = DeveloperSimulation.Vehicles[0].Id;
                }

                if (idOrPath != null)
                {
                    // find index of previously selected thing in new dataset
                    var vehicleChoices = VehicleChoices;
                    var selected       = vehicleChoices.FindIndex(v => v.idOrPath == idOrPath);
                    SetVehicleFromSelectionIndex(vehicleChoices, selected);

                    await UpdateCloudVehicleDetails();
                }

                DeveloperSimulation.NPCs = Config.NPCVehicles.Values.ToArray(); // TODO get from cloud and refresh config.cs LoadExternalAssets()
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
                ErrorMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    ErrorMessage += "\n" + ex.InnerException.Message;
                }
                API.Disconnect();
            }
            finally
            {
                updating = false;
                Repaint();
            }
        }
        async void Refresh()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                return;
            }

            try
            {
                updating     = true;
                ErrorMessage = "";
                Simulator.Web.Config.ParseConfigFile();

                await UpdateVersions();

                try
                {
                    // FIXME also list and find bundles and cloud bridges?
                    var bridgesAssembly = Assembly.Load("Simulator.Bridges");
                    Bridges = bridgesAssembly.GetTypes()
                              .Where(ty => typeof(IBridgeFactory).IsAssignableFrom(ty) && !ty.IsAbstract)
                              .Select(ty => BridgePlugins.GetNameFromFactory(ty)).ToArray();
                }
                catch { }

                if (DeveloperSimulation.Cluster == null)
                {
                    DeveloperSimulation.Cluster = new ClusterData()
                    {
                        Name      = "DeveloperSettingsDummy",
                        Instances = new[]
                        {
                            new InstanceData
                            {
                                HostName   = "dummy.developer.settings",
                                Ip         = new [] { "127.0.0.1" },
                                MacAddress = "00:00:00:00:00:00"
                            }
                        }
                    };
                }

                if (string.IsNullOrEmpty(Config.CloudProxy))
                {
                    API = new CloudAPI(new Uri(Config.CloudUrl), Config.SimID);
                }
                else
                {
                    API = new CloudAPI(new Uri(Config.CloudUrl), Config.SimID, new Uri(Config.CloudProxy));
                }

                DatabaseManager.Init();
                var            csservice = new Simulator.Database.Services.ClientSettingsService();
                ClientSettings cls       = csservice.GetOrMake();
                Config.SimID = cls.simid;
                if (string.IsNullOrEmpty(Config.CloudUrl))
                {
                    ErrorMessage = "Cloud URL not set";
                    return;
                }
                if (string.IsNullOrEmpty(Config.SimID))
                {
                    linked       = false;
                    ErrorMessage = "Simulator not linked";
                    return;
                }

                var ret = await API.GetLibrary <VehicleDetailData>();

                CloudVehicles = ret.ToList();

                string[] guids = AssetDatabase.FindAssets("t:Prefab", new[] { "Assets/External/Vehicles" });
                LocalVehicles = guids.Select(g => AssetDatabase.GUIDToAssetPath(g)).ToList();

                string idOrPath = null;
                if (DeveloperSimulation.Vehicles != null) // get previously selected thing
                {
                    // we abuse VehicleData.Id to store the prefab path
                    idOrPath = EgoVehicle.Id;
                }

                if (idOrPath != null)
                {
                    // find index of previously selected thing in new dataset
                    var foundIndex = VehicleChoices.FindIndex(v => v.cloudIdOrPrefabPath == idOrPath && (v.IsLocal || v.configId == Settings.VehicleConfigId));
                    SetVehicleFromSelectionIndex(foundIndex);
                    updateVehicleDetails = true;
                    await UpdateCloudVehicleDetails();
                }

                DeveloperSimulation.NPCs = Config.NPCVehicles.Values.ToArray(); // TODO get from cloud and refresh config.cs LoadExternalAssets()
            }
            catch (CloudAPI.NoSuccessException ex)
            {
                if (ex.StatusCode == System.Net.HttpStatusCode.Unauthorized)
                {
                    ErrorMessage = "This instance requires linking to a cluster on " + Config.CloudUrl;
                    linked       = false;
                }
                else
                {
                    Debug.LogException(ex);
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
                ErrorMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    ErrorMessage += "\n" + ex.InnerException.Message;
                }
            }
            finally
            {
                updating = false;
                Repaint();
            }
        }
        async void Refresh()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                return;
            }

            try
            {
                updating     = true;
                ErrorMessage = "";
                Simulator.Web.Config.ParseConfigFile();

                if (DeveloperSimulation.Cluster == null)
                {
                    DeveloperSimulation.Cluster = new ClusterData()
                    {
                        Name      = "DeveloperSettingsDummy",
                        Instances = new[]
                        {
                            new InstanceData
                            {
                                HostName   = "dummy.developer.settings",
                                Ip         = new [] { "127.0.0.1" },
                                MacAddress = "00:00:00:00:00:00"
                            }
                        }
                    };
                }

                if (string.IsNullOrEmpty(Config.CloudProxy))
                {
                    API = new CloudAPI(new Uri(Config.CloudUrl), cookieContainer);
                }
                else
                {
                    API = new CloudAPI(new Uri(Config.CloudUrl), cookieContainer, new Uri(Config.CloudProxy));
                }

                DatabaseManager.Init();
                var            csservice = new Simulator.Database.Services.ClientSettingsService();
                ClientSettings cls       = csservice.GetOrMake();
                Config.SimID = cls.simid;
                if (String.IsNullOrEmpty(Config.CloudUrl))
                {
                    ErrorMessage = "Cloud URL not set";
                    return;
                }
                if (String.IsNullOrEmpty(Config.SimID))
                {
                    ErrorMessage = "Simulator not linked";
                    return;
                }

                if (cookieContainer.GetCookies(new Uri(Config.CloudUrl)).Count == 0)
                {
                    authenticated = false;
                }

                if (authenticated)
                {
                    var ret = await API.GetLibrary <VehicleDetailData>();

                    CloudVehicles = ret.ToList();
                }
                else
                {
                    CloudVehicles = new List <VehicleDetailData>();
                }

                string[] guids = AssetDatabase.FindAssets("t:Prefab", new[] { "Assets/External/Vehicles" });
                LocalVehicles = guids.Select(g => AssetDatabase.GUIDToAssetPath(g)).ToList();

                string idOrPath = null;
                if (DeveloperSimulation.Vehicles != null) // get previously selected thing
                {
                    // we abuse VehicleData.Id to store the prefab path
                    idOrPath = DeveloperSimulation.Vehicles[0].Id;
                }

                if (idOrPath != null)
                {
                    // find index of previously selected thing in new dataset
                    var foundIndex = VehicleChoices.FindIndex(v => v.cloudIdOrPrefabPath == idOrPath && (v.IsLocal || v.configId == Settings.VehicleConfigId));
                    SetVehicleFromSelectionIndex(foundIndex);

                    await UpdateCloudVehicleDetails();
                }

                DeveloperSimulation.NPCs = Config.NPCVehicles.Values.ToArray(); // TODO get from cloud and refresh config.cs LoadExternalAssets()
            }
            catch (CloudAPI.NoSuccessException ex)
            {
                if (ex.StatusCode == System.Net.HttpStatusCode.BadRequest)
                {
                    authenticated = false;
                    ClearCookie();
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
                ErrorMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    ErrorMessage += "\n" + ex.InnerException.Message;
                }
            }
            finally
            {
                updating = false;
                Repaint();
            }
        }