Ejemplo n.º 1
0
        /// <summary>
        /// (not android ) only! Android资源不在目录!
        /// Editor返回文件系统目录,运行时返回StreamingAssets目录
        /// </summary>
        /// <param name="url"></param>
        /// <param name="withFileProtocol">是否带有file://前缀</param>
        /// <param name="newUrl"></param>
        /// <returns></returns>
        public static bool TryGetInAppStreamingUrl(string url, bool withFileProtocol, out string newUrl)
        {
            if (withFileProtocol)
            {
                newUrl = PackagePathUrl + url;
            }
            else
            {
                newUrl = PackagePath + url;
            }

#if UNITY_ANDROID
            // Android平台下StreamingAssetsPath,在apk包里面,使用原生插件做文件检查
            if (!ResAndroidPlugin.IsAssetExists(url))
            {
                return(false);
            }
#else
            if (!File.Exists(PackagePath + url))
            {
                return(false);
            }
#endif
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// check file exists of streamingAssets. On Android will use plugin to do that.
        /// </summary>
        /// <param name="path">relative path,  when file is "file:///android_asset/test.txt", the pat is "test.txt"</param>
        /// <returns></returns>
        public static bool IsStreamingAssetsExists(string path)
        {
#if UNITY_ANDROID && !UNITY_EDITOR
            return(ResAndroidPlugin.IsAssetExists(path));
#else
            return(File.Exists(Path.Combine(Application.streamingAssetsPath, path)));
#endif
        }