Unity-Technologies / 2d-extras

Fun 2D Stuff that we'd like to share!
Other
1.55k stars 343 forks source link

Trouble setting animated tiles from script in build, but not in editor #314

Closed hal9yo closed 3 years ago

hal9yo commented 3 years ago

A script that sets Tilemap Tiles to AnimatedTiles runs successfully when the game is played in the Editor.

But when I build the game and then run it from the build the tiles are not being set.

The following error is showing up in the log, and seems related, (I do not think any other script I am running has an #ifdef UNITY_EDITOR):

A scripted object (script unknown or not yet loaded) has a different serialization layout when loading. (Read 48 bytes but expected 164 bytes) Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts? (Filename: Line: 2324)

ChuanXin-Unity commented 3 years ago

Hi, could you share which version of the 2D Extras you are using, and possibly the script which you are using to set the Tiles? Thanks!

hal9yo commented 3 years ago

Water.cs.txt

I believe I have the latest version of the file, I just grabbed the version on this repo, in the Runtime folder (AnimatedTile.cs) to make sure.

I hope this is an appropriate way to share the script I am using to set the tiles (I uploaded it as a .txt file)

To be sure I included the version I am using here:

AnimatedTile.cs.txt

ChuanXin-Unity commented 3 years ago

Creating a test player with your Water.cs script and the Animated Tile seem fine. I am not certain if there could be other scripts that could cause this issue.

Would it be possible to share the project that has this issue by using the Unity Bug Reporter and post the case number here? Thanks!

hal9yo commented 3 years ago

Ok, I'll do this tomorrow, I need some sleep.

Thank you.