Skip to content

Instantly share code, notes, and snippets.

@WikkidEdd
Last active November 19, 2023 11:45
Show Gist options
  • Save WikkidEdd/b572ce423969c114f6eea3b5a751f7d9 to your computer and use it in GitHub Desktop.
Save WikkidEdd/b572ce423969c114f6eea3b5a751f7d9 to your computer and use it in GitHub Desktop.
Creates a symlinked version of a Unity project so you can easily do network development. Add script to Editor folder. Run from "Utils/Create Symlink Project" then choose directory to put symlink'd project in.
using UnityEngine;
using UnityEditor;
using System.Diagnostics;
public class CreateSymlinkProject {
[MenuItem("Utils/Create Symlink Project")]
static void DoIt()
{
string folderName = EditorUtility.SaveFolderPanel("Symlink Project Location", "", "");
string newAssetFolder = folderName + "/Assets";
string currentAssetFolder = Application.dataPath;
string newProjectSettingsFolder = folderName + "/ProjectSettings";
string currentProjectSettingsFolder = Application.dataPath.Replace("Assets", "ProjectSettings");
string newPackagesFolder = folderName + "/Packages";
string currentPackagesFolder = Application.dataPath.Replace("Assets", "Packages");
CreateSymlink(newAssetFolder, currentAssetFolder);
CreateSymlink(newProjectSettingsFolder, currentProjectSettingsFolder);
CreateSymlink(newPackagesFolder, currentPackagesFolder);
}
static void CreateSymlink(string newFolder, string linkFolder)
{
Process.Start("cmd.exe", "/c mklink /D \"" + newFolder + "\" \"" + linkFolder + "\"");
}
}
@jethrogillgren
Copy link

Super useful, thanks.
For mac or linux:


	static void CreateSymlink(string newFolder, string linkFolder)
	{
		if (Application.platform == RuntimePlatform.WindowsEditor)
		{
			Process.Start ( "cmd.exe", "/c mklink /D \"" + newFolder + "\" \"" + linkFolder + "\"" );
		}
		else if (  Application.platform == RuntimePlatform.OSXEditor
   				|| Application.platform == RuntimePlatform.LinuxEditor )
		{
			Process.Start ( "ln", "-s \"" + linkFolder + "\" \"" + newFolder + "\"" );
		}
	}

@woozie164
Copy link

Thanks for this script!

Had some issues getting it to run on my computer though. Worked fine after manually opening cmd as administrator and running the cmds.

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