/* Setter & Getter */

        /* Functions */

        public ExportTreeView(PackageExport exportWindow, TreeViewState state)
            : base(state)
        {
            this.mPackageExport = exportWindow;
            Reload();

            ExpandAll();
        }
Exemple #2
0
        /// <summary>
        /// Export the package.
        /// </summary>
        /// <param name="name"> Name of the package. </param>
        /// <param name="version"> Version of the package. </param>
        /// <param name="savePath"> Output directory. (optional) </param>
        /// <param name="next"> True if iterate through the whole package list. </param>
        public static void Export(string name, string version, string savePath = null, bool next = false)
        {
            string finalPackageName = FormPackageName(name, version);

            string ignoreFilePath    = Application.dataPath + "/" + IGNORE_FILE_PATH + "/";
            string ignoreFileName    = name + IGNORE_FILE_EXT;
            string newIgnoreFullPath = ignoreFilePath + ignoreFileName;

            newIgnoreFullPath = newIgnoreFullPath.Replace("\\", "/");

            if (!File.Exists(newIgnoreFullPath))
            {
                return;
            }

            string[] ignoreList = ReadAllLinesWithoutComment(newIgnoreFullPath);

            string[]      exportList      = GetAllFilesAndDirInPath();
            List <string> finalExportList = new List <string>();

            foreach (string path in exportList)
            {
                string fixedPath = path.Replace("\\", "/");

                if (IgnoreExportPath(fixedPath))
                {
                    continue;
                }

                fixedPath = MakeValidExportPath(fixedPath);

                // check if this path is ignore by the .unityignore file.
                if (MakeIgnore(fixedPath, ignoreList))
                {
                    continue;
                }

                finalExportList.Add(fixedPath);
            }

            if (finalExportList.Count == 0)
            {
                Debug.Log("No file is exported, it seems like you have ignore all files");
                return;
            }

            if (savePath == null)
            {
                PackageExport.ShowExportWindow(finalPackageName, finalExportList, next);
            }
            else
            {
                string ext = ".unitypackage";
                savePath = Path.Combine(savePath, finalPackageName + ext);

                ExportPackage(finalExportList, savePath);
            }
        }