Coder Social home page Coder Social logo

Comments (5)

alffanclub avatar alffanclub commented on August 16, 2024

Hi @maskedmous. Thanks for this suggestion, but I just don't think it's doable. The challenge is that there isn't a clear mapping. When building, we have a set and specific build target. We can use that to make a consistent and deterministic path, but can't easily translate that to RuntimePlatform. For example, RuntimePlatform has "WindowsPlayer" and "WindowsEditor". So I believe you could have a build target of "StandaloneWindows" or "StandaloneWindows64", and either one could map to "WindowsPlayer" or "WindowsEditor" at runtime depending on if you are in a stand alone player or play-mode in the editor.
Thanks for the suggestion. I really appreciate people communicating how they use the tool, and what might help them succeed. Unfortunately in this case, I just don't believe I can make it work.

from assetbundles-browser.

maskedmouse avatar maskedmouse commented on August 16, 2024

Unity never really had a clear way of mapping, it still amazes me they keep 2 seperate enumerators for both BuildTarget and RuntimePlatform while they are both kind of the same just with the BuildTarget having a definition for x64 / x86 where RuntimePlatform does not.

That aside...
I did a test by building a Windows x86 build that tries to load StandaloneWindows64 built asset bundles. Worked like a charm. The actual build does not seem to care whether the bundles have been built with StandaloneWindows or StandaloneWindows64.

In the AssetBundle Manager repository it even has a utility converting the BuildTarget to RuntimePlatform and then eventually a string. https://bitbucket.org/Unity-Technologies/assetbundledemo/src/464697bcff9b5422e13950b9a9664cd0b3496d10/demo/Assets/AssetBundleManager/Utility.cs

So I am kind of uncertain how to even use the built bundles if a runtime build doesn't even know where they are located. In a runtime build I cannot get StandaloneWindows64 as a string. It would force me to embed that into my application / game on build to use StandaloneWindows64 as platform string.
Whereas either a x86 or x64 build should be capable of running with asset bundles built with either StandaloneWindows or StandaloneWindows64 according to the test I have done.

How would you suggest one get their build target as a string for it to pass in a UnityWebRequest or even just AssetBundle.LoadFromFileAsync. How would you map a url in a runtime build?

from assetbundles-browser.

alffanclub avatar alffanclub commented on August 16, 2024

Hi @maskedmous. The recommended process somewhat depends on your usage, but in either case the build path is intended as a staging folder. Generally it looks like one of these two processes:

If only using bundles locally:

  1. Build to /AssetBundles//
  2. Copy the current built bundles to StreamingAssets (probably deleting what was there)
  3. Build the game
    This will put just the current-platform bundles into StreamingAssets and thus into the build.

Or if using a server:

  1. Build to /AssetBundles// AND turn on "append hash"
  2. Copy the built bundles to the CDN server and the manifest to StreamingAssets.
  3. Build the game
    This will make your build come with a manifest that states the current hashes, and a server that has bundles accessible by hash. Thus if you built for, say, Android and iOS, each set of bundles would have different file names for the unique hashes, and thus could coexist on the server. Unfortunately this is not well documented as we are working on some future systems that will hopefully help make this level of detail unimportant.

Thanks again for reaching out. Does this explanation help?
-Bill

from assetbundles-browser.

maskedmouse avatar maskedmouse commented on August 16, 2024

in a sense yes, I get it if you're building to the streaming assets, it doesn't matter which platform it is. As long as you copy the right platform asset bundles.

I am building an Asset Bundle Manager myself which has useful event callbacks and easy access to the built asset bundles.
I've never really relied on appending the hash into the bundle name. On the server I rather divide the files into folders.
i.e server.com/Game/AssetBundles/iPhonePlayer/1.0.0/bundlename
I fetch the manifest from the server, it contains all the info I need such as the hashes and bundle names and dependencies.
I process the bundle name and possible variant with the manifest.
I format the url $"server.com/Game/AssetBundles/{Application.platform}/{Application.version}/{bundlename}" and pass it to the UnityWebRequest.GetAssetBundle(url, hash, 0)

This way when I upload new bundles to the server the application will notice that there has been an update in the manifest because one or more asset bundles got a new hash. I grab the header, ask the user if they want to download the update of X size and then proceed downloading the bundle.

With the AssetBundle Browser I can build the bundles but I will have to make a tool asside to upload the asset bundles to the server with their proper naming i.e iPhonePlayer. I'd have to manually convert iOS into iPhonePlayer or StandaloneWindows64 into WindowsPlayer.

Well I guess I'll go with making a tool which saves the asset bundle in their right spot on the server.
And whenever building to the StreamingAssets i'll just put it directly into the streaming assets without thinking of the platform as they should be copied from the right platform before building.

Thanks for the useful insight, didn't think of the local solution.
The server solution I kind of know what direction I'm going for now.

from assetbundles-browser.

alffanclub avatar alffanclub commented on August 16, 2024

Sounds good. Glad you have a solution that works for you, and am sorry it doesn't quite align with how we're setting up the general case.
I would suggest, if you're going to write custom code to do your upload, that you write it inside the browser. The reason we have it on Github is so that users can easily customize it for their own needs.
Feel free to reach out with other ideas. I always appreciate feedback,
Bill

from assetbundles-browser.

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.