Ejemplo n.º 1
0
 public static void UninstallLibFolder(string path)
 {
     if (SA_AssetDatabase.IsDirectoryExists(path))
     {
         EditorUtility.DisplayProgressBar("Stan's Assets.", "Uninstalling: " + path, 1);
         SA_AssetDatabase.DeleteAsset(path);
         EditorUtility.ClearProgressBar();
     }
 }
Ejemplo n.º 2
0
        private static void ResolveBinaryLibs(AN_AndroidBuildRequirements requirements)
        {
            if (AN_Settings.Instance.UseUnityJarResolver)
            {
                AN_Dependencies.Resolve(requirements.BinaryDependencies);
                SA_AssetDatabase.DeleteAsset(AN_Settings.ANDROID_MAVEN_FOLDER);
            }
            else
            {
                AN_Dependencies.Resolve(new List <AN_BinaryDependency>());


                List <string> repositorysToAdd    = new List <string>();
                List <string> repositorysToRemove = new List <string>();

                List <string> mavenLibs = SA_AssetDatabase.FindAssetsWithExtentions(AN_Settings.ANDROID_MAVEN_FOLDER);
                foreach (var lib in mavenLibs)
                {
                    //we are only interested in folder, we also assume all folders are located inside a root folder
                    if (!SA_AssetDatabase.IsValidFolder(lib))
                    {
                        continue;
                    }

                    string libName = SA_AssetDatabase.GetFileName(lib);
                    if (!requirements.HasBinaryDependency(libName))
                    {
                        repositorysToRemove.Add(libName);
                    }
                }

                foreach (var dep in requirements.BinaryDependencies)
                {
                    string libPath = AN_Settings.ANDROID_MAVEN_FOLDER + dep.GetLocalRepositoryName();
                    if (!SA_AssetDatabase.IsDirectoryExists(libPath))
                    {
                        string localRepositoryName = dep.GetLocalRepositoryName();
                        if (!repositorysToAdd.Contains(localRepositoryName))
                        {
                            repositorysToAdd.Add(localRepositoryName);
                        }
                    }
                }

                SA_PluginsEditor.UninstallLibs(AN_Settings.ANDROID_MAVEN_FOLDER, repositorysToRemove);

                foreach (var lib in repositorysToAdd)
                {
                    string source      = AN_Settings.ANDROID_MAVEN_FOLDER_DISABLED + lib;
                    string destination = AN_Settings.ANDROID_MAVEN_FOLDER + lib;
                    SA_PluginsEditor.InstallLibFolder(source, destination);
                }
            }
        }
Ejemplo n.º 3
0
        private static void ResolveXMLConfig(List <string> dependencies)
        {
            //Clean up file if we have no Dependencies
            if (dependencies.Count == 0)
            {
                if (SA_AssetDatabase.IsDirectoryExists(AN_Settings.DEPENDENCIES_FOLDER))
                {
                    SA_AssetDatabase.DeleteAsset(AN_Settings.DEPENDENCIES_FOLDER);
                }
                s_activeDependencies = new List <string>();
                return;
            }

            if (IsEqualsToActiveDependencies(dependencies))
            {
                return;
            }

            if (!SA_AssetDatabase.IsValidFolder(AN_Settings.DEPENDENCIES_FOLDER))
            {
                SA_AssetDatabase.CreateFolder(AN_Settings.DEPENDENCIES_FOLDER);
            }


            var doc = new XmlDocument();
            var dependenciesElement    = doc.CreateElement("dependencies");
            var androidPackagesElement = doc.CreateElement("androidPackages");


            foreach (var dependency in dependencies)
            {
                var androidPackage = doc.CreateElement("androidPackage");

                var spec = doc.CreateAttribute("spec");
                spec.Value = dependency;
                androidPackage.Attributes.Append(spec);

                androidPackagesElement.AppendChild(androidPackage);
            }

            dependenciesElement.AppendChild(androidPackagesElement);
            doc.AppendChild(dependenciesElement);
            doc.Save(SA_PathUtil.ConvertRelativeToAbsolutePath(AN_Settings.DEPENDENCIES_FILE_PATH));
            SA_AssetDatabase.ImportAsset(AN_Settings.DEPENDENCIES_FILE_PATH);
            s_activeDependencies = ReadDependencies();
        }
Ejemplo n.º 4
0
        //--------------------------------------
        // Static
        //--------------------------------------

        public static void Resolve()
        {
            var versionUpdated = AN_Settings.UpdateVersion(AN_Settings.FormattedVersion) && !SA_PluginTools.IsDevelopmentMode;
            var requirements   = new AN_AndroidBuildRequirements();

            if (versionUpdated)
            {
                SA_AssetDatabase.DeleteAsset(AN_Settings.ANDROID_INTERNAL_FOLDER);
                SA_AssetDatabase.DeleteAsset(AN_Settings.ANDROID_MAVEN_FOLDER);
            }

            foreach (var resolver in Resolvers)
            {
                resolver.Run(requirements);
            }
            Resolve(requirements);
        }
Ejemplo n.º 5
0
        public static void InstallLibFolder(string source, string destination)
        {
            if (!SA_AssetDatabase.IsDirectoryExists(source))
            {
                Debug.LogError("Can't find the source lib folder at path: " + source);
                return;
            }


            //Clean before install
            if (SA_AssetDatabase.IsDirectoryExists(destination))
            {
                SA_AssetDatabase.DeleteAsset(destination);
            }

            SA_AssetDatabase.CopyAsset(source, destination);
            EnableLibsAtPath(destination);
        }
Ejemplo n.º 6
0
        public static void UninstallLibs(string path, List <string> libs)
        {
            for (int i = 0; i < libs.Count; i++)
            {
                var   lib      = libs[i];
                float progress = (float)(i + 1) / (float)libs.Count;
                EditorUtility.DisplayProgressBar("Stan's Assets.", "Uninstalling: " + lib, progress);

                string libPath = path + lib;
                if (SA_AssetDatabase.IsFileExists(libPath) || SA_AssetDatabase.IsDirectoryExists(libPath))
                {
                    SA_AssetDatabase.DeleteAsset(path + lib);
                }
                else
                {
                    Debug.LogWarning("There is no file to deleted at: " + libPath);
                }
            }

            EditorUtility.ClearProgressBar();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Delete's asset instance
        /// </summary>
        public static void Delete()
        {
            string path = SA_AssetDatabase.GetAssetPath(Instance);

            SA_AssetDatabase.DeleteAsset(path);
        }