Created
February 6, 2023 23:19
-
-
Save SiarheiPilat/f16d23937adb12ff793bbaa08ec05312 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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