Пример #1
0
        /// <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);
            ClonesManager.CopyLibraryFolder(sourceProject, cloneProject);

            ClonesManager.LinkFolders(sourceProject.assetPath, cloneProject.assetPath);
            ClonesManager.LinkFolders(sourceProject.projectSettingsPath, cloneProject.projectSettingsPath);
            ClonesManager.LinkFolders(sourceProject.packagesPath, cloneProject.packagesPath);
            ClonesManager.LinkFolders(sourceProject.autoBuildPath, cloneProject.autoBuildPath);
            ClonesManager.LinkFolders(sourceProject.localPackages, cloneProject.localPackages);

            ClonesManager.RegisterClone(cloneProject);

            return(cloneProject);
        }