Git Product home page Git Product logo

Comments (9)

jamcohen avatar jamcohen commented on May 4, 2024 1

The runtime documentation is available here. Here's the part about reading those files from disk.

To load a raw asset you should:
"Use PlayAssetPackRequest.GetAssetLocation() to get an AssetLocation object. This provides the path, offset, and size of the asset so that it can be loaded from disk."

from play-unity-plugins.

jamcohen avatar jamcohen commented on May 4, 2024 1

Here's an example using a file stream to load the text into a string:

FileStream assetFileStream = File.OpenRead(assetLocation.Path);
byte[] buffer = new byte[assetLocation.Size];
assetFileStream.Seek((long) assetLocation.Offset, SeekOrigin.Begin);
assetFileStream.Read(buffer, /* offset= */ 0, buffer.Length);
string fileContents = Encoding.UTF8.GetString(buffer, 0, buffer.Length);

Are you doing something similar?

from play-unity-plugins.

jamcohen avatar jamcohen commented on May 4, 2024

Thanks for raising this issue. Currently the runtime API lags behind the packaging API a bit. We are working on updating the runtime API with a method that allows you to access the raw assets inside of those packs, but that functionality isn't supported yet.

In the meantime as a workaround/hack, you can use Unity's TextAsset to have GameObjects reference arbitrary files. Then you can package those GameObjects in AssetBundles and access the files using TextAsset.bytes.

from play-unity-plugins.

heshuimu avatar heshuimu commented on May 4, 2024

Thank you for clarifying. I am currently not there yet with my project where lacking this feature would be an issue so I can wait for now.

from play-unity-plugins.

jamcohen avatar jamcohen commented on May 4, 2024

Update: We added experimental support for this in the v1.1.1 release. If you want to give it a try, you can enable the PLAY_ASSET_DELIVERY_EXPERIMENTAL preprocessor definition in player settings (see the "Platform custom #defines" section here for how to do that)

from play-unity-plugins.

shwuhk avatar shwuhk commented on May 4, 2024

@jamcohen May I know how to get Raw Asset now?

from play-unity-plugins.

shwuhk avatar shwuhk commented on May 4, 2024

@jamcohen Thanks for your help. We get the AssetLocation object but find that we can't load that file out. It would be good if you could show us some light.

This is the { path / size / offset } of the AssetLocation object { /data/app/com.DefaultCompany.TestAB-KRpgbnLxvKt8DzJ3vu3IKg==/split_assets.apk / 620847 / 2188 }. This should be a simple .txt file but we find that we could not read this file out with Readerstream using the path above.

from play-unity-plugins.

shwuhk avatar shwuhk commented on May 4, 2024

This really help!
Thanks!!

from play-unity-plugins.

jamcohen avatar jamcohen commented on May 4, 2024

Happy to help! I'll close this issue, but feel free to reopen if you're still having trouble.

from play-unity-plugins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.