Example #1
0
        private static void GenerateUnityIgnoreFiles()
        {
            string ignoreTemplatePath     = Application.dataPath + "/" + TEMPLATE_PATH + "/";
            string ignoreFileTemplatePath = ignoreTemplatePath + IGNORE_FILE_TEMPLATE_FILE;

            string[] templateLines = File.ReadAllLines(ignoreFileTemplatePath);

            for (int index = 0;
                 index < instance.exportPackagesList.Length;
                 ++index)
            {
                ExportPackageStruct eps = instance.exportPackagesList[index];

                string packageName = eps.packageName;
                string versionNo   = eps.versionNo;

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

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


                if (!File.Exists(newIgnoreFullPath))
                {
                    FileStream fileStream = new FileStream(newIgnoreFullPath,
                                                           FileMode.OpenOrCreate,
                                                           FileAccess.ReadWrite,
                                                           FileShare.None);

                    // make header, date, info, etc.
                    string[] decoratedTemplateLines = MakeDecoration(templateLines, packageName, versionNo);

                    using (StreamWriter sw = new StreamWriter(fileStream))
                    {
                        foreach (string line in decoratedTemplateLines)
                        {
                            sw.WriteLine(line);
                        }
                    }
                }
            }

            // reset asset database once.
            AssetDatabase.Refresh();
        }
Example #2
0
        private static void ExportAllPackages()
        {
            for (int index = 0;
                 index < instance.exportPackagesList.Length;
                 ++index)
            {
                ExportPackageStruct eps = instance.exportPackagesList[index];

                /* GUI Layout */
                string packageName = eps.packageName;
                string versionNo   = eps.versionNo;

                string finalPackageName = packageName + DELIMITER + VERSION_SYMBOL + versionNo;

                if (versionNo == "")
                {
                    finalPackageName = packageName;
                }

                if (packageName == "")
                {
                    finalPackageName = DEFAULT_PACKAGE_NAME;
                }

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

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

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

                string[] ignoreList = ReadAllLinesWithoutComment(newIgnoreFullPath);

                Export(finalPackageName, ignoreList);
            }
        }
Example #3
0
        /// <summary>
        /// Intialize tile editor.
        /// </summary>
        private void OnEP_Editor()
        {
            GUILayout.Space(TITLE_SPACE_TOP);
            GUILayout.Label("** Packages Settings **", EditorStyles.boldLabel);
            GUILayout.Space(TITLE_SPACE_BOTTOM);

            /* Export the whole list. */
            {
                ScriptableObject   target          = this;
                SerializedObject   so              = new SerializedObject(target);
                SerializedProperty stringsProperty = so.FindProperty("exportPackagesList");

                EditorGUILayout.PropertyField(stringsProperty, true);
                so.ApplyModifiedProperties();
            }

            GUILayout.Space(TITLE_SPACE_TOP);
            GUILayout.Label("** Unity Ignore File **", EditorStyles.boldLabel);
            GUILayout.Space(TITLE_SPACE_BOTTOM);

            if (GUILayout.Button("Generate Unity Ignore"))
            {
                GenerateUnityIgnoreFiles();
            }

            GUILayout.Space(TITLE_SPACE_TOP);
            GUILayout.Label("** Export Packages **", EditorStyles.boldLabel);
            GUILayout.Space(TITLE_SPACE_BOTTOM);

            int buttonShown = 0;


            for (int index = 0;
                 index < instance.exportPackagesList.Length;
                 ++index)
            {
                ExportPackageStruct eps = instance.exportPackagesList[index];

                /* GUI Layout */
                string packageName = eps.packageName;
                string versionNo   = eps.versionNo;

                string finalPackageName = packageName + DELIMITER + VERSION_SYMBOL + versionNo;

                if (versionNo == "")
                {
                    finalPackageName = packageName;
                }

                if (packageName == "")
                {
                    finalPackageName = DEFAULT_PACKAGE_NAME;
                }

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

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

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

                string[] ignoreList = ReadAllLinesWithoutComment(newIgnoreFullPath);

                ++buttonShown;

                /* Assign export button. */
                if (GUILayout.Button("Export -> " + finalPackageName))
                {
                    Export(finalPackageName, ignoreList);
                }
            }

            if (buttonShown >= EXPORT_ALL_PACKAGES_BUTTON_COUNT)
            {
                if (GUILayout.Button("Export All Packages"))
                {
                    ExportAllPackages();
                }
            }
        }