Search Unity

  1. How can our website serve you better? Give us your feedback. Take our survey and let us know.
    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:
    23
    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:
    630
    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)
     
    JimChan88 likes this.
  3. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    630
    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 JimChan88 like this.
unityunity