Skip to content

Instantly share code, notes, and snippets.

@BigETI
Created October 28, 2020 17:31
Show Gist options
  • Save BigETI/6b4e0f241cd55cf2751ec2000431680a to your computer and use it in GitHub Desktop.
Save BigETI/6b4e0f241cd55cf2751ec2000431680a to your computer and use it in GitHub Desktop.
Creates an empty Unity project. Loads very quickly!
#include <iostream>
#include <filesystem>
#include <fstream>
static void WriteToFile(const std::filesystem::path& path, const std::string& contents)
{
std::ofstream ofs(path.string());
if (ofs.is_open())
{
ofs << contents;
}
}
int main(int argc, char* argv[])
{
try
{
if (argc > 1)
{
std::filesystem::path project_directory_path(argv[1]);
std::filesystem::path assets_directory(project_directory_path / "Assets");
std::filesystem::path packages_directory(project_directory_path / "Packages");
std::filesystem::path project_settings_directory(project_directory_path / "ProjectSettings");
if (std::filesystem::create_directories(assets_directory) &&
std::filesystem::create_directories(packages_directory) &&
std::filesystem::create_directories(project_settings_directory))
{
std::string editor_version((argc > 2) ? argv[2] : "2020.1.4f1");
std::filesystem::path manifest_json_path(packages_directory / "manifest.json");
std::filesystem::path project_version_txt_path(project_settings_directory / "ProjectVersion.txt");
WriteToFile(manifest_json_path, "{\"dependencies\": {}}\n");
WriteToFile(project_version_txt_path, "m_EditorVersion: " + editor_version);
}
}
}
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
}
catch (...)
{
std::cerr << "An unknown error has occured :(" << std::endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment