/// <summary> /// Copies the full contents of the unity library. We want to do this to avoid the lengthy re-serialization of the whole project when it opens up the clone. /// </summary> /// <param name="sourceProject"></param> /// <param name="destinationProject"></param> public static void CopyLibraryFolder(Project sourceProject, Project destinationProject) { if (Directory.Exists(destinationProject.libraryPath)) { Debug.LogWarning("Library copy: destination path already exists! "); return; } Debug.Log("Library copy: " + destinationProject.libraryPath); ClonesManager.CopyDirectoryWithProgressBar(sourceProject.libraryPath, destinationProject.libraryPath, "Cloning project '" + sourceProject.name + "'. "); }
/// <summary> /// Creates clone of the project located at the given path. /// </summary> /// <param name="sourceProjectPath"></param> /// <returns></returns> public static Project CreateCloneFromPath(string sourceProjectPath) { Project sourceProject = new Project(sourceProjectPath); string cloneProjectPath = null; //Find available clone suffix id for (int i = 0; i < MaxCloneProjectCount; i++) { string originalProjectPath = ClonesManager.GetCurrentProject().projectPath; string possibleCloneProjectPath = originalProjectPath + ClonesManager.CloneNameSuffix + "_" + i; if (!Directory.Exists(possibleCloneProjectPath)) { cloneProjectPath = possibleCloneProjectPath; break; } } if (string.IsNullOrEmpty(cloneProjectPath)) { Debug.LogError("The number of cloned projects has reach its limit. Limit: " + MaxCloneProjectCount); return(null); } Project cloneProject = new Project(cloneProjectPath); Debug.Log("Start cloning project, original project: " + sourceProject + ", clone project: " + cloneProject); ClonesManager.CreateProjectFolder(cloneProject); //Copy Folders Debug.Log("Library copy: " + cloneProject.libraryPath); ClonesManager.CopyDirectoryWithProgressBar(sourceProject.libraryPath, cloneProject.libraryPath, "Cloning Project Library '" + sourceProject.name + "'. "); Debug.Log("Packages copy: " + cloneProject.libraryPath); ClonesManager.CopyDirectoryWithProgressBar(sourceProject.packagesPath, cloneProject.packagesPath, "Cloning Project Packages '" + sourceProject.name + "'. "); //Link Folders ClonesManager.LinkFolders(sourceProject.assetPath, cloneProject.assetPath); ClonesManager.LinkFolders(sourceProject.projectSettingsPath, cloneProject.projectSettingsPath); ClonesManager.LinkFolders(sourceProject.autoBuildPath, cloneProject.autoBuildPath); ClonesManager.LinkFolders(sourceProject.localPackages, cloneProject.localPackages); ClonesManager.RegisterClone(cloneProject); return(cloneProject); }