Search Unity

combining addressable with oculus expansion files

Discussion in 'Addressables' started by shashkes, Aug 27, 2019.

  1. shashkes

    shashkes

    Joined:
    Mar 16, 2017
    Posts:
    19
    I'm trying to keep my APK file below the maximum oculus allows by using addressable and bundles that I can upload to ocululs as expansion files. (https://developer.oculus.com/blog/tech-note-expansion-files-with-unity/)

    My understanding is that I should treat these addressables as local build files because they will be downloaded automatically from oculus into the android device when users download the game. Is this correct?

    I've managed to update my scripts so they load the files with async function but I'm having a difficult time getting the build .apk to not include the addressable assets and instead building with a separate asset bundle file, they way I used to do with normal asset bundle creation.
    I've been trying to set different local build paths but am getting an error:

    LoadPath for group Default Local Group is set to the dynamic-lookup version of StreamingAssets, but BuildPath is not. These paths must both use the dynamic-lookup, or both not use it.
    BuildPath: 'Assests/AssetBundles'
    LoadPath: '{UnityEngine.AddressableAssets.Addressables.RuntimePath}/[BuildTarget]'
    UnityEditor.GenericMenu:CatchMenu(Object, String[], Int32)

    What path should I put under local build path? if i put the streaming asset folder don't the addressable get attached to the build .apk file no matter what?

    should I click the toggle button "include in build" or not?

    then assuming I find where the actual bundles are getting saved and manage to upload to oculus (i managed to do this with the regular asset bundle system which required renaming as described in the link above) when oculus downloads the bundles what is the local path I want unity to load from?
    If anyone has experience with this unique combo I would be happy to pay for a few hours of your time to consult on this. I tried looking for a unity expert on unity but the search didn't find anyone listing addressables
    thanks
     
  2. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    Giving the oculus doc a quick skim, I think you need a custom build script.

    - Set group BuildPath to something like "OculusFiles/Stuff" (Not a folder in Assets)
    - during build, use the custom build script to rename the file we make (something.bundle) to what oculus wants (
    main.<version>.<package>.obb) -- it sounds like oculus may want only one bundle, so you'll have to put all download stuff in one group marked as "pack together" but I'm not sure of that
    - Set the group LoadPath to where oculus says you'll load the stuff (/sdcard/Android/obb/com.oculus.demo/ or something)

    then things should just work. maybe.
     
  3. shashkes

    shashkes

    Joined:
    Mar 16, 2017
    Posts:
    19
    thanks! oculus now allows multiple extension files. https://developer.oculus.com/documentation/platform/latest/concepts/dg-dlc/?locale=en_US
    when i set the build folder to outside of assets as you suggested and also put a local folder for loading ( for now )i was able to build the bundle and rename it manually to what oculus wants. I also unchecked include in build and my .apk file shrunk which is what i needed. now just need to figure the correct load path from the sdcard.
     
  4. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    "include in build" means "include this stuff when building content". So if you uncheck that, the content in that group won't be built into any bundles.

    You should be able to just build them to an alternate location, but keep that checkbox checked.
     
  5. shashkes

    shashkes

    Joined:
    Mar 16, 2017
    Posts:
    19
    thanks, thought it meant include in the .apk and not build a seperate bundle
     
    unity_bill likes this.
  6. shashkes

    shashkes

    Joined:
    Mar 16, 2017
    Posts:
    19
    well I have all the asset bundles named and in the right place but they are still not loading, getting this error in the log of the oculus go
    09-04 02:21:24.131 9866 9881 E Unity : Dependency operation failed with System.Exception: Dependency Exception.
    09-04 02:21:24.131 9866 9881 E Unity : UnityEngine.DebugLogHandler:Internal_Log()
    09-04 02:21:24.131 9866 9881 E Unity : UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    09-04 02:21:24.131 9866 9881 E Unity : UnityEngine.Logger:LogFormat(LogType, String, Object[])
    09-04 02:21:24.131 9866 9881 E Unity : UnityEngine.Debug:LogErrorFormat(String, Object[])
    09-04 02:21:24.131 9866 9881 E Unity : UnityEngine.AddressableAssets.AddressablesImpl:LogException(AsyncOperationHandle, Exception) (at C:\$Data\VR\Live\Library\PackageCache\com.unity.addressables@1.1.10\Runtime\AddressablesImpl.cs:149)

    When I tried this specifically with loading a scene from an addressable asset I got the error:

    Scene 'Assets/Scenes/SampleScene.unity' couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded.
    UnityEngine.SceneManagement.SceneManager:LoadSceneAsyncNameIndexInternal_Injected()
    09-04 02:01:47.193 8056 8074 E Unity : UnityEngine.SceneManagement.SceneManager:LoadSceneAsyncNameIndexInternal(String, Int32, LoadSceneParameters, Boolean)
    09-04 02:01:47.193 8056 8074 E Unity : UnityEngine.SceneManagement.SceneManager:LoadSceneAsync(String, LoadSceneParameters)
    09-04 02:01:47.193 8056 8074 E Unity : UnityEngine.ResourceManagement.ResourceProviders.SceneOp:InternalLoad(String, Boolean, LoadSceneMode) (at C:\$Data\VR\Live\Library\PackageCache\com.unity.addressables@1.1.10\Runtime\ResourceManager\ResourceProviders\SceneProvider.cs:75)
    09-04 02:01:47.193 8056 8074 E Unity : UnityEngine.ResourceManagement.ResourceProviders.SceneOp:InternalLoadScene(IResourceLocation, Boolean, LoadSceneMode, Boolean, Int32) (at C:\$Data\VR\Live\Library\PackageCache\com.unity.addressables@1.1.10\Runtime\ResourceManager\ResourceProviders\SceneProvider.cs:66)
    09-04 02:01:47.193 8056 8074 E Unity : Unity
    09-04 02:01:47.281 8056 8074 E Unity : NullReferenceException: Object reference not set to an instance of an object
    09-04 02:01:47.281 8056 8074 E Unity : at UnityEngine.ResourceManagement.ResourceProviders.SceneProvider+SceneOp.InternalLoadScene (UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation location, System.Boolean loadingFromBundle, UnityEngine.SceneManagement.LoadSceneMode loadMode, System.Boolean activateOnLoad, System.Int32 priority) [0x00010] in C:\$Data\VR\Live\Library\PackageCache\com.unity.addressables@1.1.10\Runtime\ResourceManager\ResourceProviders\SceneProvider.cs:67
    09-04 02:01:47.281 8056 8074 E Unity : at UnityEngine.ResourceManagement.ResourceProviders.SceneProvider+SceneOp.Execute () [0x00070] in C:\$Data\VR\Live\Library\PackageCache\com.unity.addressables@1.1.10\Runtime\ResourceManager\ResourceProviders\SceneProvider.cs:60
    09-04 02:01:47.281 8056 8074 E Unity : at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].InvokeExecute () [0x00001] in C:\$Data\VR\Live\Library\PackageCache\com.unity.addressables@1.1.10\Runtime\ResourceManager\AsyncOperations\AsyncOperationBase.cs:391
    09-04 02:01:47.281 8056 8074 E Unity : at UnityEn
    09-04 02:01:49.887 956 983 W ActivityManager: Unable to start service Intent { act=com.google.android.gms.ads.identifier.service.START pkg=com.google.android.gms } U=0: not found


    Wondering if I got the android manifest file wrong and didn't put the external permission in the right place, this is my manifest file:

    <?xml version="1.0" encoding="utf-8" standalone="no"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    android:installLocation="auto">
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <!-- Request the headset DoF mode -->
    <application
    android:allowBackup="false">
    <activity
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
    android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
    android:launchMode="singleTask"
    android:name="com.unity3d.player.UnityPlayerActivity"
    android:excludeFromRecents="true">
    <intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
    </activity>
    <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="false" />

    </application>
    </manifest>

    any suggestions would be greatly appreciated!
     
  7. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    Unfortunately I haven't done much oculus dev, so I'm not sure what might be going on here. I'd suggest putting some debugging into the AssetBundleProvider (this is the thing that loads the bundle). That will help you figure out the full path it's trying to load from, and how that load is going.
     
  8. ihe_unity

    ihe_unity

    Joined:
    Dec 21, 2018
    Posts:
    1
    Hi, Shashkes
    Have you found the solution to this?
     
  9. wliyang

    wliyang

    Joined:
    Mar 21, 2020
    Posts:
    8
    Hi. Unity_Bill.
    Is it possible for me to use addressables and obb expantion files?
     
    TheVirtualMunk and baconbap like this.
  10. TheVirtualMunk

    TheVirtualMunk

    Joined:
    Sep 6, 2019
    Posts:
    150
    It's been a year and there is still no information or examples of Addressables working with .obb files. Have tried the suggestions here but nothing works on build, and the logs and errors are completely useless. This is just a guessing game by now...

    Honestly, it's much easier and simpler with old school AssetBundles, although you have to do some manual work to get it working on both editor and build - just too bad the addressable abstraction level is so poorly documented like every other new package coming out of Unity's pipeline.
     
  11. glenneroo

    glenneroo

    Joined:
    Oct 27, 2016
    Posts:
    231
    Also wondering this before I transition everything over from AssetBundles. Documentation is still quite sparse, does anyone have any experience and/or good tutorials who can chime in here?
     
  12. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    755
    I also need more information on how to manage this, please
     
  13. nocanwin

    nocanwin

    Joined:
    May 7, 2009
    Posts:
    176
    It's possible. Do a split binary build and rename the obb to what oculus wants. main.1.com.company.project.obb. 1 is the version number. See oculus's docs. Install the apk and copy the obb and any bundles to Android/obb/com.company.project/. The addressables group Load Path should be set to sdcard/Android/obb/com.company.project/ Make sure you're NOT using Addressables 1.16.16. Even though it's "verified" it tries to load bundles from the Build Path instead of Load Path. It's works in 1.16.10 and 1.17.15. I think it might work in 1.16.16 if you use append hash to filename, but I haven't verified.
     
  14. bpj_mdt

    bpj_mdt

    Joined:
    May 17, 2021
    Posts:
    8
    Has anyone had any success with this? I am in an identical situation and looking for a solution.
     
  15. jirimotejlek

    jirimotejlek

    Joined:
    Nov 8, 2016
    Posts:
    20
    Advice given by neocanwin in #13 seems to be working.
     
  16. Hambone_fakenamington

    Hambone_fakenamington

    Joined:
    Mar 15, 2021
    Posts:
    1
    Has anyone come across a better blog/document than the oculus blog post, that explains how to best do the addressable/expantion file thing from first principals?
    Thanks
     
  17. nathanjams

    nathanjams

    Joined:
    Jul 27, 2016
    Posts:
    304
    Also interested in this.

    Do you need to use both or could you just use addressables and pull that content directly to the quest headset?
     
  18. jana553

    jana553

    Joined:
    May 31, 2018
    Posts:
    7
    Here are some of the things we followed to achieve this
    Advice given by neocanwin in #13 will be helpful if you have apk file and obb file.

    if you have multiple bundles built using addressalbles, we can use oculus asset files
    https://developer.oculus.com/documentation/unity/ps-assets/

    upload all the bundles as asset files and make sure you set remote load path properly in addressalbles config in your project.
    ex: if we have obb it will be the obb file location where oculus will download asset files.

    if you want the bundle to be downloaded at install time, use --asset-files-config while uploading the apk & asset files using ovr-platform-util
     
    Eclectus and nathanjams like this.
  19. nathanjams

    nathanjams

    Joined:
    Jul 27, 2016
    Posts:
    304
    Thank you very much @jana553

    I'll give this a go.

    Nathan
     
  20. Eclectus

    Eclectus

    Joined:
    Oct 29, 2012
    Posts:
    20
    The advice given by newcanwin in #13 is very helpful:

    It allowed me to combine Addressables with asset Bundles, and then upload extra expansion files for each bundle
    upload_2022-5-30_0-52-7.png

    Here is an example bat file for pushing to Quest:

    Code (CSharp):
    1. adb kill-server
    2. adb start-server
    3.  
    4. REM Remove previously installed version
    5. adb uninstall com.company.project
    6. adb shell rm /sdcard/Android/obb/main.0.com.company.project.obb
    7.  
    8.  
    9. REM Install the APK file
    10. cd ../Builds/
    11. adb push -p project.apk /data/local/tmp
    12. adb shell pm install -g /data/local/tmp/project.apk
    13. adb shell rm /data/local/tmp/project.apk
    14.  
    15. if exist "main.32.com.company.project.obb" (
    16.     REM Deleting the old "main.0.com.company.project.obb"
    17.     del "main.0.com.company.project.obb"
    18. )
    19.  
    20. if exist "project.main.obb" (
    21.     REM Copy and rename the expansion file
    22.     copy /y /b /v project.main.obb main.1.com.company.project.obb
    23. )
    24.  
    25. REM Make the directory
    26. adb shell mkdir /sdcard/Android/obb/com.company.project/
    27.  
    28. REM Push the expansion file
    29. adb push -p main.1.com.company.project.obb /sdcard/Android/obb/com.company.project/
    30.  
    31. REM Push an assets bundle file
    32. adb push -p ../AssetBundles/name-of-asset-file_assets_all.bundle /sdcard/Android/obb/com.company.project/
    33.  
    34. pause
    Here is an example of uploading to the Oculus store:

    Code (CSharp):
    1. REM https://developer.oculus.com/resources/publish-reference-platform-command-line-utility/
    2. REM https://developer.oculus.com/documentation/native/ps-assets/
    3. .\ovr-platform-util upload-quest-build --app_id [appid] --token [token] --apk ..\Builds\project.apk --obb ..\Builds\project.main.obb --assets_dir ..\AssetBundles --asset-files-config ..\AssetBundles\expansion-files-config.json --channel alpha --notes "Some notes here"
    4.  
    5. pause
     
  21. OmnifariousStudios

    OmnifariousStudios

    Joined:
    Mar 12, 2018
    Posts:
    48
    So I've tried the steps here, but this still isn't working for me.

    Everything works perfectly in the editor, but when I do what noCanWin said in the forums and use Split Application Binary and make a build, it can't find my files. My addressables definitely build, I can see that my OBB file is 3x the size of my APK, and when I convert it to a zip and open it, I can see the files are there. I made sure to name the OBB file correctly and put it into the correct folder in the quest's file directory.

    Everything should be downloaded at install time, not worried about updates or DLC right now. Just want to get the files stored locally.

    The error I get when trying to load a scene is RemoteProviderException : TextDataProvider: unable to load from url : jar:file:///data/app/com... etc


    I'm using Unity 2019.4.32 and Addressables 1.18.19


    Any help would be extremely appreciated, and at this point I'd even be happy to pay someone for their time to help fix this.
     
  22. ScottJustScott

    ScottJustScott

    Joined:
    Nov 15, 2022
    Posts:
    6
    Just want to toss out some appreciation to @Eclectus. Was able to follow #20 near exactly (project name swapped, etc) and got a > 5gb amount of content to upload to meta and pull down and play on Quest.
     
  23. adrian-taylor09

    adrian-taylor09

    Joined:
    Dec 22, 2016
    Posts:
    63
    Is anyone having trouble setting a custom build and load path for addressables?

    I can build an addressable group just fine if I leave teh build and load paths to one of the default options, but when I try and set a custom path I get an error message
     

    Attached Files: