Skip to content

Instantly share code, notes, and snippets.

@SiarheiPilat
Created February 6, 2023 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiarheiPilat/f16d23937adb12ff793bbaa08ec05312 to your computer and use it in GitHub Desktop.
Save SiarheiPilat/f16d23937adb12ff793bbaa08ec05312 to your computer and use it in GitHub Desktop.
using UnityEditor;
using UnityEngine;
public class BuildToDesktop
{
[MenuItem("File/Build to Desktop")]
public static void BuildGame()
{
string dateTime = System.DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss");
string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop) + "/Build_" + dateTime;
if (!System.IO.Directory.Exists(path))
{
System.IO.Directory.CreateDirectory(path);
BuildPipeline.BuildPlayer(EditorBuildSettings.scenes, path, BuildTarget.WebGL, BuildOptions.None);
}
else
{
Debug.LogError("Folder already exists, something went wrong!..");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment