Skip to content

Commit

Permalink
OBB fix, readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
gwiazdorrr committed Dec 9, 2019
1 parent 8eea85e commit d612274
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
13 changes: 10 additions & 3 deletions Assets/Plugins/BetterStreamingAssets/BSA_BetterStreamingAssets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ private static int GetDirectoryIndex(string path)

// find first file there
var index = Array.BinarySearch(s_paths, path, StringComparer.OrdinalIgnoreCase);
if ( index > 0 )
if ( index >= 0 )
return ~index;

// if the end, no such directory exists
Expand Down Expand Up @@ -577,15 +577,22 @@ private static void GetStreamingAssetsInfoFromJar(string apkPath, List<string> p
var fileName = Encoding.UTF8.GetString(header.Filename);
if (fileName.StartsWith(prefix) && !fileName.StartsWith(assetsPrefix))
{
Debug.LogAssertionFormat("BetterStreamingAssets: file {0} seems to be a Streaming Asset, but is compressed. Ignoring.", fileName);
Debug.LogAssertionFormat("BetterStreamingAssets: file {0} seems to be a Streaming Asset, but is compressed. If this is a App Bundle build, see README for a possible workaround.", fileName);
}
#endif
// we only want uncompressed files
}
else
{
var fileName = Encoding.UTF8.GetString(header.Filename);
if ( fileName.StartsWith(prefix) )

if (fileName.EndsWith("/"))
{
// there's some strangeness when it comes to OBB: directories are listed as files
// simply ignoring them should be enough
Debug.Assert(header.UncompressedSize == 0);
}
else if ( fileName.StartsWith(prefix) )
{
// ignore normal assets...
if ( fileName.StartsWith(assetsPrefix) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class BetterStreamingAssetsTests
private const int TexturesCount = 2;
private const int BundlesTypesCount = 3;

private const string TestDirName = "BSATest";
private const string TestDirName = "bsatest";
private const string TestPath = "Assets/StreamingAssets/" + TestDirName;
private const string TestResourcesPath = "Assets/Resources/" + TestDirName;
private const int TestFiles = SizesCount * 2 + SizesCount * 2 * BundlesTypesCount + TexturesCount * BundlesTypesCount + TexturesCount;
Expand Down Expand Up @@ -48,10 +48,10 @@ public static void GenerateTestData()
long mb = 1024 * 1024;
foreach ( var size in SizesMB )
{
var p = "Assets/raw_compressable_" + size.ToString("00") + "MB.bytes";
var p = "Assets/raw_compressable_" + size.ToString("00") + "mb.bytes";
paths.Add(p);
CreateZeroFile(p, size * mb);
p = "Assets/raw_uncompressable_" + size.ToString("00") + "MB.bytes";
p = "Assets/raw_uncompressable_" + size.ToString("00") + "mb.bytes";
paths.Add(p);
CreateRandomFile(p, size * mb, random);
}
Expand Down
4 changes: 4 additions & 0 deletions Assets/Plugins/BetterStreamingAssets/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Support/Feedback: [email protected]
Twitter: @gwiazdorrr
Support Page: http://dmprog.pl/unity-plugins/

Note on Android & App Bundles
------------------
App Bundles (.aab) builds are bugged when it comes to Streaming Assets. See https://github.com/gwiazdorrr/BetterStreamingAssets/issues/10 for details. The bottom line is:
!!! Keep all file names in Streaming Assets lowercase! !!!

Usage:
------
Expand Down

0 comments on commit d612274

Please sign in to comment.