public async Task CreateAndThenEditFile()
        {
            PublishedFileId fileid;

            //
            // Make a file
            //
            {
                var result = await Ugc.Editor.NewCommunityFile
                             .WithTitle("Unedited File")
                             .SubmitAsync();

                Assert.IsTrue(result.Success);
                Assert.AreNotEqual(result.FileId.Value, 0);

                fileid = result.FileId;
            }

            await Task.Delay(1000);

            //
            // Edit it
            //
            {
                var editor = new Ugc.Editor(fileid);
                editor = editor.WithTitle("An Edited File");
                var result = await editor.SubmitAsync();

                Assert.IsTrue(result.Success);
                Assert.AreEqual(result.FileId, fileid);
            }

            await Task.Delay(1000);

            //
            // Make sure the edited file matches
            //
            {
                var details = await SteamUGC.QueryFileAsync(fileid) ?? throw new Exception("Somethign went wrong");

                Assert.AreEqual(details.Id, fileid);
                Assert.AreEqual(details.Title, "An Edited File");
            }

            //
            // Clean up
            //
            var deleted = await SteamUGC.DeleteFileAsync(fileid);

            Assert.IsTrue(deleted);
        }
Exemple #2
0
        private async Task PublishToSteam(string folder)
        {
            Steamworks.Ugc.Editor editor = new Steamworks.Ugc.Editor();
            editor = (this.ItemId != 0 ? new Steamworks.Ugc.Editor(this.ItemId) : Steamworks.Ugc.Editor.NewMicrotransactionFile);
            Steamworks.Ugc.Editor editor1 = editor.WithContent(folder);
            editor1 = editor1.WithPreviewFile(string.Concat(folder, "/icon_background.png"));
            editor1 = editor1.WithTitle(this.Title);
            editor1 = editor1.WithTag("Version3");
            editor1 = editor1.WithTag(this.Skinnable.Name);
            editor1 = editor1.WithTag("Skin");
            editor  = editor1.WithPublicVisibility();
            if (!string.IsNullOrEmpty(this.ChangeLog.text))
            {
                editor = editor.WithChangeLog(this.ChangeLog.text);
            }
            WorkshopItemEditor.Loading(true, "Publishing To Steam", "", 0f);
            PublishResult publishResult = await editor.SubmitAsync(null);

            if (publishResult.Success)
            {
                UnityEngine.Debug.Log(string.Concat("Published File: ", publishResult.FileId));
            }
            else
            {
                UnityEngine.Debug.Log(string.Concat("Error: ", publishResult.Result));
            }
            Item?nullable = await SteamUGC.QueryFileAsync(publishResult.FileId);

            if (nullable.HasValue)
            {
                WorkshopItemEditor id = this.Editor;
                Item value            = nullable.Value;
                id.ItemId = value.Id;
                WorkshopItemEditor title = this.Editor;
                value               = nullable.Value;
                title.ItemTitle     = value.Title;
                this.ChangeLog.text = "";
                value               = nullable.Value;
                UnityEngine.Application.OpenURL(value.Url);
                WorkshopItemList.RefreshAll();
            }
            else
            {
                UnityEngine.Debug.Log("Error Retrieving item information!");
                WorkshopItemList.RefreshAll();
            }
        }
        private async Task <PublishResult> Upload(Steamworks.Ugc.Editor editor)
        {
            if (!SteamClient.IsValid)
            {
                SteamClient.Init(Structure.AppId);
                await Task.Delay(1000);
            }

            var result = await editor.SubmitAsync(this);

            SteamClient.RunCallbacks();
            await Task.Delay(250);

            SteamClient.RunCallbacks();
            await Task.Delay(250);

            return(result);
        }