// Update is called once per frame void Update() { string url = GUIUtility.systemCopyBuffer; // Don't incur cost of checking, or bother the player, if buffer is unchanged. if (url == lastCopyBuffer) { return; } lastCopyBuffer = url; ulong workshopId = Util.ExtractIdFromWorkshopUrl(url); if (workshopId != 0) { popups.ShowTwoButtons($"You copied a Steam Workshop URL! Play it?\nDetected item ID: {workshopId}", $"Play", () => { float progress = 0f; bool keepShowing = true; var downloadingPopup = new DynamicPopup.Popup(); downloadingPopup.getMessage = () => $"Downloading.. {Mathf.Floor((progress * 100))} %"; downloadingPopup.keepShowing = () => keepShowing; downloadingPopup.isCancellable = false; popups.Show(downloadingPopup); string displayName = $"Item {workshopId}"; workshopSource.Get(workshopId, path => { keepShowing = false; if (path.IsEmpty()) { popups.ShowWithCancel($"Woops - could not download the workshop item. Maybe restart and try again?\nMessage: {path.GetErrorMessage()}", "OK", null, 800f); } else { loadingScreen.ShowAndDo(() => sceneController.LoadWorkshopItem( new LoadableWorkshopItem { displayName = displayName, installedLocalFolder = path.Get(), steamId = workshopId }, new GameBuilderApplication.PlayOptions(), null)); } }, prog => progress = prog, // TODO could also grab thumbnail async.. item => displayName = item.Name ); }, "Cancel", () => { }); } }