0

I build a test project to get a minimal reproducible script, and this does it:

using UnityEngine;
using UnityEngine.Tilemaps;

public class TileTest : MonoBehaviour {
    public Tilemap tilemap;
    public Sprite floorSprite;

    void Start () {
        Tile tile = new Tile();

        tile.sprite = floorSprite;
        tilemap.SetTile(new Vector3Int(1, 1, 0), tile);

        tile = ScriptableObject.CreateInstance<Tile>();
        tile.sprite = floorSprite;
        tilemap.SetTile(new Vector3Int(-1, -1, 0), tile);
    }
}

The sprite is just a small PNG, and the tilemap is a Tilemap object inside of a Grid (normal). This script is attached to the grid. That's exactly all there is to this project.

In the editor and in Android builds, both of the instantiations work. The first generates a warning, which is expected (it's deprecated); I just wanted to try directly to see if the behavior varied, which it doesn't.

I can't find anything in Build Settings or PlayerSettings that seems like it should impact this. The sprite is referenced on the script on the grid, and just to make sure, I put the Sprites folder in a Resources folder; no change. Firefox and Chrome/Chromium (I've tested this in Windows 10 and Debian 9) both just display a blank canvas, which is the right color for the build (and in the more complex projects it also displays my non-tile sprites and animations), but no tile sprites render.

In the actual project, I'm dynamically instantiating prefabs with animations that work fine across all platforms. Why would it be failing in WebGL?

gman
  • 100,619
  • 31
  • 269
  • 393
kungphu
  • 4,592
  • 3
  • 28
  • 37

1 Answers1

3

This is a current bug with the Unity engine and will be patched in a future release. Keep your eyes on the following, as well as changelogs for Unity going forward.

Unity Bug Tracker - Tilemap WebGL

James Whyte
  • 788
  • 3
  • 14
  • 1
    Ugh... not sure how this didn't come up while I was searching for what *I* had done wrong. Thanks a lot for the information. – kungphu Apr 11 '18 at 03:54
  • No problem, mate. I'll keep looking about for a fix and if I find something I will comment below with the solution. – James Whyte Apr 11 '18 at 03:54
  • Much appreciated; I'll do the same. The only targets I ever intended for Unity deployment are WebGL and Android; 1 out of 2 ain't good. – kungphu Apr 11 '18 at 03:59