Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

jethrogillgren commented Mar 2, 2018

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

This comment has been minimized.

Copy link

woozie164 commented Nov 21, 2018

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
You can’t perform that action at this time.