コード例 #1
0
        private static List <string> ReadDependencies()
        {
            var result = new List <string>();

            try {
                if (SA_AssetDatabase.IsFileExists(AN_Settings.DEPENDENCIES_FILE_PATH))
                {
                    var doc = new XmlDocument();
                    doc.Load(SA_PathUtil.ConvertRelativeToAbsolutePath(AN_Settings.DEPENDENCIES_FILE_PATH));
                    var xnList = doc.SelectNodes("dependencies/androidPackages/androidPackage");

                    foreach (XmlNode xn in xnList)
                    {
                        var spec = xn.Attributes["spec"].Value;
                        result.Add(spec);
                    }
                }
            } catch (Exception ex) {
                AN_Logger.LogError("Error reading AN_Dependencies");
                AN_Logger.LogError(AN_Settings.DEPENDENCIES_FILE_PATH + " filed: " + ex.Message);
            }



            return(result);
        }
コード例 #2
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));
        }
コード例 #3
0
        private static bool IsPathEqualsSDKName(string assetPath, string SDKName)
        {
            var fileName  = SA_PathUtil.GetFileName(assetPath);
            var extension = SA_PathUtil.GetExtension(assetPath);

            return(fileName.Contains(SDKName) && extension.Equals(".dll"));
        }
コード例 #4
0
        private static string GetJarResolverVersion(string assetPath, string SDKName)
        {
            string version = SA_PathUtil.GetFileNameWithoutExtension(assetPath);

            if (version.Contains(SDKName))
            {
                try
                {
                    version = version.Remove(0, SDKName.Length);
                    if (version.Length > 0 && version[0].Equals('_'))
                    {
                        version = version.Remove(0, 1);
                    }
                    return(version);
                }
                catch (Exception ex)
                {
                    AN_Logger.LogError(string.Format("Error at getting Jar Resolver version - {0}", ex.Message));
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
コード例 #5
0
        //--------------------------------------
        //  Private Methods
        //--------------------------------------


        private static void CheckForAdMobSDK(string assetPath, bool enable)
        {
            string fileName = SA_PathUtil.GetFileName(assetPath);

            if (fileName.Equals(ADMOB_LIB_FOLDER_NAME))
            {
                UpdateSDKDefine(enable, ADMOB_INSTALLED_DEFINE);
            }
        }
コード例 #6
0
        private void ValidateAssets <T>(List <T> assets, string requiredLocation, string requiredExtension) where T : Object
        {
            //Let's make sure we aren't missing assets under requiredLocation
            var assetPaths = SA_AssetDatabase.FindAssetsWithExtentions(requiredLocation, requiredExtension);

            foreach (var assetPath in assetPaths)
            {
                var assetExtension = SA_PathUtil.GetExtension(assetPath);
                if (assetExtension.Equals(requiredExtension))
                {
                    var file = (T)AssetDatabase.LoadAssetAtPath(assetPath, typeof(T));
                    if (!assets.Contains(file))
                    {
                        assets.Add(file);
                        return;
                    }
                }
            }

            for (var i = 0; i < assets.Count; i++)
            {
                var asset = assets[i];
                if (asset == null)
                {
                    //We do not allow null element's unless this is a last element
                    if (i != assets.Count - 1)
                    {
                        assets.Remove(asset);
                        return;
                    }
                    continue;
                }

                if (!HasValidExtension(asset, requiredExtension))
                {
                    EditorGUILayout.HelpBox(asset.name + " need to be in *" + requiredExtension + " format.", MessageType.Error);
                    continue;
                }

                if (!SA_AssetDatabase.IsAssetInsideFolder(asset, requiredLocation))
                {
                    EditorGUILayout.HelpBox(asset.name + " has to be inside: \n" + requiredLocation, MessageType.Error);
                    using (new SA_GuiBeginHorizontal()) {
                        GUILayout.FlexibleSpace();
                        var move = GUILayout.Button("Move", EditorStyles.miniButton);
                        if (move)
                        {
                            var currentPath = AssetDatabase.GetAssetPath(asset);
                            var assetName   = SA_AssetDatabase.GetFileName(currentPath);
                            var newPath     = requiredLocation + assetName;
                            SA_AssetDatabase.MoveAsset(currentPath, newPath);
                        }
                    }
                }
            }
        }
コード例 #7
0
        //--------------------------------------
        // Private Methods
        //--------------------------------------


        private static string FixRelativePath(string path, bool validateFoldersPath = true)
        {
            path = SA_PathUtil.FixRelativePath(path);
            if (validateFoldersPath)
            {
                ValidateFoldersPath(path);
            }

            return(path);
        }
コード例 #8
0
        private static void CheckForUnityAdsSDK(string assetPath, bool enabled)
        {
            string fileName = SA_PathUtil.GetFileName(assetPath);

            if (fileName.Equals(UNITY_ADS_LIB_NAME))
            {
                UpdateSDKDefine(enabled, UNITY_ADS_INSTALLED_DEFINE);
            }

            SA_EditorDefines.RemoveCompileDefine(UNITY_ADS_INSTALLED_DEFINE, BuildTarget.tvOS);
        }
コード例 #9
0
        //--------------------------------------
        //  Private Methods
        //--------------------------------------


        private static bool IsPathEqualsSDKName(string assetPath, string SDKName)
        {
            string fileName = SA_PathUtil.GetFileName(assetPath);

            if (fileName.Equals(SDKName))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #10
0
        //--------------------------------------
        //  Private Methods
        //--------------------------------------


        private static bool IsPathEqualsFacebookSDKName(string assetPath)
        {
            string fileName = SA_PathUtil.GetFileName(assetPath);

            if (fileName.Equals(FACEBOOK_LIB_NAME))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #11
0
        private void LogCommunication(string className, string methodName, List <object> arguments)
        {
            var strippedClassName = SA_PathUtil.GetExtension(className);

            strippedClassName = strippedClassName.Substring(1);
            var argumentsLog = LogArguments(arguments);

            if (!string.IsNullOrEmpty(argumentsLog))
            {
                argumentsLog = " :: " + argumentsLog;
            }
            AN_Logger.LogCommunication("Sent to Java -> " + strippedClassName + "." + methodName + argumentsLog);
        }
コード例 #12
0
        public static void ValidateFoldersPath(string path)
        {
            string parentDir = string.Empty;

            foreach (var dir in SA_PathUtil.GetDirectoriesOutOfPath(path))
            {
                if (!IsDirectoryExists(dir))
                {
                    string dirName = SA_PathUtil.GetPathDirectoryName(dir);
                    SA_AssetDatabaseProxy.CreateFolder(parentDir, dirName);
                }
                parentDir = dir;
            }
        }
コード例 #13
0
        private bool HasValidExtension(Object asset, string requiredExtension)
        {
            var assetPath      = SA_AssetDatabase.GetAssetPath(asset);
            var assetExtension = SA_PathUtil.GetExtension(assetPath);

            if (assetExtension.Equals(requiredExtension))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #14
0
        private static bool IsPathEqualsSDKName(string assetPath, string SDKName)
        {
            string fileName  = SA_PathUtil.GetFileName(assetPath);
            string extention = SA_PathUtil.GetExtension(assetPath);

            if (fileName.Contains(SDKName) && extention.Equals(".dll"))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #15
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
        }
コード例 #16
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();
        }
コード例 #17
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
        }
コード例 #18
0
ファイル: AN_GamesIds.cs プロジェクト: Haykys/Head-Bouncer
        public AN_GamesIds(string rawData)
        {
            m_rawData = rawData;

            try {
                XmlDocument doc = new XmlDocument();
                doc.Load(SA_PathUtil.ConvertRelativeToAbsolutePath(AN_Settings.ANDROID_GAMES_IDS_FILE_PATH));
                XmlNodeList xnList = doc.SelectNodes("resources/string");

                foreach (XmlNode node in xnList)
                {
                    string name = node.Attributes["name"].Value;
                    if (name.Equals("app_id"))
                    {
                        app_id = node.InnerText;
                    }

                    if (name.Equals("package_name"))
                    {
                        package_name = node.InnerText;
                    }

                    if (name.StartsWith("achievement") && name.Contains("_"))
                    {
                        var key   = name.Split('_')[1];
                        var value = node.InnerText;
                        m_achievements.Add(new KeyValuePair <string, string>(key, value));
                    }

                    if (name.StartsWith("leaderboard") && name.Contains("_"))
                    {
                        var key   = name.Split('_')[1];
                        var value = node.InnerText;
                        m_leaderboards.Add(new KeyValuePair <string, string>(key, value));
                    }
                }
            } catch (Exception ex) {
                AN_Logger.LogError("Error reading AN_GamesIds");
                AN_Logger.LogError(AN_Settings.ANDROID_GAMES_IDS_FILE_PATH + " filed: " + ex.Message);
            }
        }
コード例 #19
0
        public static void DrawRequirementsUI(AN_AndroidBuildRequirements buildRequirements)
        {
            if (buildRequirements.Activities.Count > 0)
            {
                using (new SA_H2WindowBlockWithSpace(new GUIContent("ACTIVITIES"))) {
                    foreach (var activity in buildRequirements.Activities)
                    {
                        string name = SA_PathUtil.GetExtension(activity.Name);
                        name = name.Substring(1, name.Length - 1);
                        var icon = AN_Skin.GetIcon("requirements_activity.png");
                        SA_EditorGUILayout.SelectableLabel(new GUIContent("activity: " + name, icon));
                    }
                }
            }


            if (buildRequirements.ApplicationProperties.Count > 0)
            {
                using (new SA_H2WindowBlockWithSpace(new GUIContent("APP PROPERTIES"))) {
                    foreach (var property in buildRequirements.ApplicationProperties)
                    {
                        var    icon = AN_Skin.GetIcon("requirements_activity.png");
                        string name = SA_PathUtil.GetExtension(property.Name);
                        name = name.Substring(1, name.Length - 1);

                        SA_EditorGUILayout.SelectableLabel(new GUIContent(property.Tag + ": " + name, icon));
                    }
                }
            }

            if (buildRequirements.ManifestProperties.Count > 0)
            {
                using (new SA_H2WindowBlockWithSpace(new GUIContent("MANIFEST PROPERTIES"))) {
                    foreach (var property in buildRequirements.ManifestProperties)
                    {
                        var icon = AN_Skin.GetIcon("requirements_activity.png");

                        string info = string.Empty;
                        foreach (var pair in property.Values)
                        {
                            info += " " + pair.Key + " : " + pair.Value;
                        }

                        SA_EditorGUILayout.SelectableLabel(new GUIContent(property.Tag + info, icon));
                    }
                }
            }


            if (buildRequirements.Permissions.Count > 0)
            {
                using (new SA_H2WindowBlockWithSpace(new GUIContent("PERMISSIONS"))) {
                    foreach (var permission in buildRequirements.Permissions)
                    {
                        var icon = AN_Skin.GetIcon("requirements_permission.png");
                        SA_EditorGUILayout.SelectableLabel(new GUIContent(permission.GetFullName(), icon));
                    }
                }
            }

            if (buildRequirements.BinaryDependencies.Count > 0)
            {
                using (new SA_H2WindowBlockWithSpace(new GUIContent("BINARY DEPENDENCIES"))) {
                    foreach (var dependency in buildRequirements.BinaryDependencies)
                    {
                        var icon = AN_Skin.GetIcon("requirements_lib.png");
                        SA_EditorGUILayout.SelectableLabel(new GUIContent(dependency.GetRemoteRepositoryName(), icon));
                    }
                }
            }
        }
コード例 #20
0
        private void ReadManifest(string manifestPath)
        {
            m_template = new AMM_Template();


            if (!SA_AssetDatabase.IsFileExists(manifestPath))
            {
                return;
            }

#if !(UNITY_WP8 || UNITY_METRO)
            //Read XML file
            XmlDocument doc = new XmlDocument();
            doc.Load(SA_PathUtil.ConvertRelativeToAbsolutePath(manifestPath));
            XmlNode rootNode = doc.DocumentElement;

            foreach (XmlAttribute attr in rootNode.Attributes)
            {
                m_template.SetValue(attr.Name, attr.Value);
            }

            foreach (XmlNode childNode in rootNode.ChildNodes)
            {
                if (!childNode.Name.Equals("application") &&
                    !childNode.Name.Equals("uses-permission") &&
                    !childNode.Name.Equals("#comment"))
                {
                    m_template.AddProperty(childNode.Name, AMM_Manager.ParseProperty(childNode));
                }
            }

            XmlNode applicationNode = null;
            foreach (XmlNode childNode in rootNode.ChildNodes)
            {
                if (childNode.Name.Equals("application"))
                {
                    applicationNode = childNode;
                    break;
                }
            }

            foreach (XmlAttribute attr in applicationNode.Attributes)
            {
                m_template.ApplicationTemplate.SetValue(attr.Name, attr.Value);
            }
            foreach (XmlNode childNode in applicationNode.ChildNodes)
            {
                if (!childNode.Name.Equals("#comment") &&
                    !childNode.Name.Equals("activity"))
                {
                    m_template.ApplicationTemplate.AddProperty(childNode.Name, AMM_Manager.ParseProperty(childNode));
                }
            }

            foreach (XmlNode childNode in applicationNode.ChildNodes)
            {
                if (childNode.Name.Equals("activity") &&
                    !childNode.Name.Equals("#comment"))
                {
                    string activityName = "";
                    if (childNode.Attributes["android:name"] != null)
                    {
                        activityName = childNode.Attributes["android:name"].Value;
                    }
                    else
                    {
                        Debug.LogWarning("Android Manifest contains activity tag without android:name attribute.");
                    }

                    XmlNode launcher   = null;
                    bool    isLauncher = false;
                    foreach (XmlNode actNode in childNode.ChildNodes)
                    {
                        if (actNode.Name.Equals("intent-filter"))
                        {
                            foreach (XmlNode intentNode in actNode.ChildNodes)
                            {
                                if (intentNode.Name.Equals("category"))
                                {
                                    if (intentNode.Attributes["android:name"].Value.Equals("android.intent.category.LAUNCHER"))
                                    {
                                        isLauncher = true;
                                        launcher   = actNode;
                                    }
                                }
                            }
                        }
                    }

                    AMM_ActivityTemplate activity = new AMM_ActivityTemplate(isLauncher, activityName);
                    foreach (XmlAttribute attr in childNode.Attributes)
                    {
                        activity.SetValue(attr.Name, attr.Value);
                    }

                    foreach (XmlNode actNode in childNode.ChildNodes)
                    {
                        if (!actNode.Name.Equals("#comment"))
                        {
                            if (actNode != launcher)
                            {
                                activity.AddProperty(actNode.Name, AMM_Manager.ParseProperty(actNode));
                            }
                        }
                    }

                    m_template.ApplicationTemplate.AddActivity(activity);
                }
            }

            //Load Manifest Permissions
            foreach (XmlNode node in rootNode.ChildNodes)
            {
                if (node.Name.Equals("uses-permission"))
                {
                    AMM_PropertyTemplate permission = new AMM_PropertyTemplate("uses-permission");
                    permission.SetValue("android:name", node.Attributes["android:name"].Value);
                    m_template.AddPermission(permission);
                }
            }
#endif
        }
コード例 #21
0
 /// <summary>
 /// Determines whether the given path refers to an existing directory on disk
 /// </summary>
 /// <param name="path"> Filesystem project folder relative path.</param>
 public static bool IsDirectoryExists(string path)
 {
     return(SA_PathUtil.IsDirectoryExists(path));
 }
コード例 #22
0
 /// <summary>
 /// Returns the file name and extension of the specified path string.
 /// </summary>
 /// <param name="filePath">Filesystem project folder relative file path.</param>
 /// <returns></returns>
 public static string GetFileName(string filePath)
 {
     return(SA_PathUtil.GetFileName(filePath));
 }
コード例 #23
0
 /// <summary>
 /// Determines whether the given path refers to an existing file on disk
 /// </summary>
 /// <param name="path"> Filesystem project folder relative path.</param>
 public static bool IsFileExists(string path)
 {
     return(SA_PathUtil.IsFileExists(path));
 }
コード例 #24
0
 /// <summary>
 /// Returns the extension of the specified path string.
 /// </summary>
 /// <param name="filePath">Filesystem project folder relative file path.</param>
 /// <returns></returns>
 public static string GetExtension(string filePath)
 {
     return(SA_PathUtil.GetExtension(filePath));
 }
コード例 #25
0
        /// <summary>
        ///  Returns the absolute path name relative of a given asset
        ///  for example: "/Users/user/Project/Assets/MyTextures/hello.png".
        /// </summary>
        /// <param name="assetObject"> A reference to the asset. </param>
        public static string GetAbsoluteAssetPath(Object assetObject)
        {
            string relativePath = GetAssetPath(assetObject);

            return(SA_PathUtil.ConvertRelativeToAbsolutePath(relativePath));
        }