Exemplo n.º 1
0
        public void SaveManifest()
        {
#if !(UNITY_WP8 || UNITY_METRO)
            if (!SA_AssetDatabase.IsFileExists(m_path))
            {
                string m_folderPath = SA_PathUtil.GetDirectoryPath(m_path);
                if (!SA_AssetDatabase.IsValidFolder(m_folderPath))
                {
                    SA_AssetDatabase.CreateFolder(m_folderPath);
                }
            }

            XmlDocument newDoc = new XmlDocument();
            //Create XML header
            XmlNode docNode = newDoc.CreateXmlDeclaration("1.0", "UTF-8", null);
            newDoc.AppendChild(docNode);

            XmlElement child = newDoc.CreateElement("manifest");
            child.SetAttribute("xmlns:android", "http://schemas.android.com/apk/res/android");
            child.SetAttribute("xmlns:tools", "http://schemas.android.com/tools");
            child.SetAttribute("package", "com.stansassets.androidnative");

            m_template.ToXmlElement(newDoc, child);
            newDoc.AppendChild(child);


            newDoc.Save(SA_PathUtil.ConvertRelativeToAbsolutePath(m_path));

            //Replace 'android___' pattern with 'android:'
            TextReader reader      = new StreamReader(SA_PathUtil.ConvertRelativeToAbsolutePath(m_path));
            string     src         = reader.ReadToEnd();
            string     pattern     = @"android___";
            string     replacement = "android:";
            Regex      regex       = new Regex(pattern);
            src = regex.Replace(src, replacement);

            pattern     = @"tools___";
            replacement = "tools:";
            regex       = new Regex(pattern);
            src         = regex.Replace(src, replacement);
            reader.Close();

            TextWriter writer = new StreamWriter(SA_PathUtil.ConvertRelativeToAbsolutePath(m_path));
            writer.Write(src);
            writer.Close();

            AssetDatabase.Refresh();
#endif
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
        public static void SaveManifest()
        {
#if !(UNITY_WP8 || UNITY_METRO)
            if (!SA_AssetDatabase.IsFileExists(AMM_Settings.MANIFEST_FILE_PATH))
            {
                //Make sure we have a folder
                if (!SA_AssetDatabase.IsValidFolder(AMM_Settings.MANIFEST_FOLDER_PATH))
                {
                    SA_AssetDatabase.CreateFolder(AMM_Settings.MANIFEST_FOLDER_PATH);
                }
            }

            XmlDocument newDoc = new XmlDocument();
            //Create XML header
            XmlNode docNode = newDoc.CreateXmlDeclaration("1.0", "UTF-8", null);
            newDoc.AppendChild(docNode);

            XmlElement child = newDoc.CreateElement("manifest");
            s_template.ToXmlElement(newDoc, child);
            newDoc.AppendChild(child);


            newDoc.Save(SA_PathUtil.ConvertRelativeToAbsolutePath(AMM_Settings.MANIFEST_FILE_PATH));

            //Replace 'android___' pattern with 'android:'
            TextReader reader      = new StreamReader(SA_PathUtil.ConvertRelativeToAbsolutePath(AMM_Settings.MANIFEST_FILE_PATH));
            string     src         = reader.ReadToEnd();
            string     pattern     = @"android___";
            string     replacement = "android:";
            Regex      regex       = new Regex(pattern);
            src = regex.Replace(src, replacement);

            pattern     = @"tools___";
            replacement = "tools:";
            regex       = new Regex(pattern);
            src         = regex.Replace(src, replacement);
            reader.Close();

            TextWriter writer = new StreamWriter(SA_PathUtil.ConvertRelativeToAbsolutePath(AMM_Settings.MANIFEST_FILE_PATH));
            writer.Write(src);
            writer.Close();

            AssetDatabase.Refresh();
    #endif
        }