Skip to content

Instantly share code, notes, and snippets.

@MacaylaMarvelous81
Last active December 1, 2022 05:43
Show Gist options
  • Save MacaylaMarvelous81/3eaf505b2102ad2c3a2ccc26bd2893f5 to your computer and use it in GitHub Desktop.
Save MacaylaMarvelous81/3eaf505b2102ad2c3a2ccc26bd2893f5 to your computer and use it in GitHub Desktop.
code snippet - Uploading to the Steam Workshop (by Jeremy Wolf, one wheel studio, src: https://onewheelstudio.com/blog/2020/12/3/steam-workshop-with-unity-and-facepunch-steamworks)
private static async Task UploadLevelToSteamWorkshopAsync(string levelName)
{
Debug.Log("Uploading...");
//app data path is to the folder
//my files are stored in a folder with the same name as the level name
string appDataPath = ES3Settings.defaultSettings.FullPath;
appDataPath = appDataPath.Replace("SaveFile.es3", levelName);
//the preview path is to the image file
//I used jpeg for a smaller file size
string previewPath = appDataPath + "/" + levelName + ".jpeg";
WML Specific bits
var result = await Steamworks.Ugc.Editor.NewCommunityFile
.WithTitle(levelName)
.WithDescription(description) // the description is just a string
.WithTag("Level")
.WithTag("Beta")
.WithContent(appDataPath)
.WithPreviewFile(previewPath)
.WithPublicVisibility()
.SubmitAsync(new ProgressClass());
Debug.Log("Successfully Uploaded:" + result.Success + " Needs Agreement: " + result.NeedsWorkshopAgreement);
if (result.Success == false)
{
ErrorMessage.ShowErrorMessage("Upload of Files Failed... Please Let the developer know.");
uploadFailed?.Invoke();
}
wml specific bits
}

This gist is just code from an image from the linked post, copied into text by hand. It is prone to human error and there may be inconsistencies between the gist and the image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment