Ejemplo n.º 1
0
        /// <summary>
        /// Load file from 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 byte[] LoadByteFromStreamingAssets(string path)
        {
            if (!IsStreamingAssetsExists(path))
            {
                throw new Exception("Not exist StreamingAssets path: " + path);
            }

#if UNITY_ANDROID
            return(ResAndroidPlugin.GetAssetBytes(path));
#else
            return(File.ReadAllBytes(Path.Combine(Application.streamingAssetsPath, path)));
#endif
        }
Ejemplo n.º 2
0
        public static byte[] ReadAllBytes(string path)
        {
            var getResPathType = GetBundleFullPath(path, out var fullPath);

            if (getResPathType == ResPathType.Invalid)
            {
                return(null);
            }

#if UNITY_ANDROID
            if (getResPathType == ResPathType.InApp)
            {
                return(ResAndroidPlugin.GetAssetBytes(path));
            }
#endif
            return(File.ReadAllBytes(fullPath));
        }