GetAssetBytes() public static method

Call from java get asset file bytes
public static GetAssetBytes ( string path ) : byte[]
path string
return byte[]
示例#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[] LoadSyncFromStreamingAssets(string path)
        {
            if (!IsStreamingAssetsExists(path))
                throw new Exception("Not exist StreamingAssets path: " + path);

            if (Application.platform == RuntimePlatform.Android)
                return KEngineAndroidPlugin.GetAssetBytes(path);

            var fullPath = Path.Combine(Application.streamingAssetsPath, path);
            return ReadAllBytes(fullPath);
        }
示例#2
0
        /// <summary>
        /// Load file. 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[] LoadAssetsSync(string path)
        {
            string fullPath = GetResourceFullPath(path, false);

            if (string.IsNullOrEmpty(fullPath))
            {
                return(null);
            }

            if (Application.platform == RuntimePlatform.Android)
            {
                return(KEngineAndroidPlugin.GetAssetBytes(fullPath));
            }

            return(ReadAllBytes(fullPath));
        }