Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Get acces to external JSON file with Single Output HTML build (WASM)

Discussion in 'Project Tiny' started by Rangerz132, Jun 22, 2021.

  1. Rangerz132

    Rangerz132

    Joined:
    Feb 3, 2019
    Posts:
    38
    Hello everybody!
    I'm currently building a game using Unity Tiny and I would like to have a external JSON file with all the levels configuration. The problem is that I'm able to make it work without the "Single Output HTML" checked from the WASM build configuration but I MUST use the "Single Output HTML" option due to the platform I'm launching my game with.

    My game is simply not able to find the file.

    Capture.JPG


    Thanks!
     
  2. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    How are you loading that JSON file?
    For loading external assets i would suggest you to extend from Tiny GenericAssetLoader in Tiny Core. You can use as a base their implementation of image loading from HTML in Image2DIOHTML.cs on the package Tiny For Web (com.unity.tiny.web)
     
    Schiznitz3301 likes this.
  3. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    I have taken this approach and created a package for Asset loading.
    It basically loads any file data as byte and store it in a IBufferElement data. It works for both Desktop and Web right now.
     
    eatbuckshot and Schiznitz3301 like this.
  4. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    Check the Asset Loader package I've release here