Unable to load target when split in OBB Expansion, because Streaming assets folder is inside OBB expansion ?

0 votes
asked Apr 9, 2018 by alienkani (190 points)

Hello, I am working on AR application with Unity 3D but my application size is more than 100 MB, so i decided  to split it into Binary OBB expansion but when i split the application it stops loading Target. may be the reason behind it is because StreamingAssets folder is split in OBB expansion file. please help me. i am wondering from last month. thank You so much.

3 Answers

0 votes
answered Apr 10, 2018 by albert52 (31,850 points)
I don't think this method is feasible. Is your application primarily AR or AR is just a small feature?
0 votes
answered Jan 1, 2019 by tmartinez88 (270 points)
Hey any luck with this? Same problem here.
0 votes
answered Sep 24, 2019 by playcurio (160 points)
Problems and solutions when using unity obb (EasyAR 3.0.1)

1. AR target is not recognized.

2. Obb won't load in android marshmallow version.

solution.

1. When splitting to obb, we need to load the target image onto the mobile device.

unity First Scene Add

    private IEnumerator ExtractState()

{

       string[] filesInOBB = {

        "image.jpg", "image2.png",  // your Image targets

        };

        foreach (var filename in filesInOBB)

        {

            string uri = Application.streamingAssetsPath + "/Foldername/" + filename;

            string outputFilePath = Application.persistentDataPath + "/Foldername/" + filename;

            if (!Directory.Exists(Path.GetDirectoryName(outputFilePath)))

                Directory.CreateDirectory(Path.GetDirectoryName(outputFilePath));

            UnityWebRequest request = UnityWebRequest.Get(uri);

            yield return request.SendWebRequest();

            Save(request, outputFilePath);

            yield return new WaitForEndOfFrame();

        }

}

    private void Save(UnityWebRequest request, string outputPath)

    {

        FileStream fs = new FileStream(outputPath, System.IO.FileMode.Create);

        fs.Write(request.downloadHandler.data, 0, (int)request.downloadedBytes);

        fs.Close();

        // Verify that the File has been actually stored

        if (File.Exists(outputPath))

        {

            Debug.Log("File successfully saved at: " + outputPath);

        }

        else

        {

            Debug.Log("Failure!! - File does not exist at: " + outputPath);

        }

    }

2. For marshmallows, unity runtime permission is required.

No matter how applied to the Androidmanifast.xml file, the obb will not load.

- Unity 2017.4

https://assetstore.unity.com/packages/tools/integration/android-runtime-permissions-117803

Take this and load the permissions. An example of the above assets is on Git Hub.

https://github.com/yasirkula/UnityAndroidRuntimePermissions

But that's not the end here.

The obb is loaded but the AR target is not recognized with an invalid key in Easyar.

Just turn off the app and start again.

That part should be corrected by EasyAR.

For now, I did an App Restart in Unity.

If it doesn't work, it will restart infinitely, so you must script it only once.

ex)

    IEnumerator PermissionState()

    {

#if UNITY_ANDROID && !UNITY_EDITOR

        AndroidRuntimePermissions.Permission[] result = AndroidRuntimePermissions.RequestPermissions("android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE");

        while (true)

        {

            if (result[0] == AndroidRuntimePermissions.Permission.Granted &&

                result[1] == AndroidRuntimePermissions.Permission.Granted)

            {

                break;

            }

            yield return null;

        }

#endif

        yield return null;

    }

- Unity 2018.3

Unity provides RunTime permissions.

    IEnumerator PermissionState()

    {

#if PLATFORM_ANDROID

        Permission.RequestUserPermission(Permission.ExternalStorageWrite);

        Permission.RequestUserPermission(Permission.ExternalStorageRead);

        yield return null;

        while (true)

        {

            if (Permission.HasUserAuthorizedPermission(Permission.ExternalStorageRead) &&

                Permission.HasUserAuthorizedPermission(Permission.ExternalStorageRead))

            {

                break;

            }

            yield return null;

        }

#endif

        yield return null;

    }
Welcome to EasyAR SDK Q&A, where you can ask questions and receive answers from other members of the community.
...