Пример #1
0
        /// <summary>
        /// Returns true if given asset is located inside the provided folder path
        /// </summary>
        public static bool IsAssetInsideFolder(Object assetObject, string folderPath)
        {
            var assetPath   = GetAssetPath(assetObject);
            var assetFolder = SA_PathUtil.GetDirectoryPath(assetPath) + SA_PathUtil.FOLDER_SEPARATOR;

            return(folderPath.Equals(assetFolder));
        }
Пример #2
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
        }