Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - MBoffin

Pages: [1]
1
Support / [SOLVED] Using 2D Toolkit TileMap prefabs with DunGen
« on: January 26, 2017, 07:31:00 am »
I tried using DunGen and 2D Toolkit during Global Game Jam 2017 last weekend and totally failed. I was setting up the TileMap prefabs correctly per instructions I've found here, but whenever I generated the map, it came out a total mess with nothing rendered correctly at all, tiles overlapping, render data all out of whack, etc. Being a game jam, I didn't have time to sort it out, but tonight I finally dug in and got it working. It seems to be a problem using TileMap prefabs and placing them at new locations during runtime. To get it working, I had to tell each TileMap to .ForceBuild() after the whole map was done being generated. Here's the script I wrote that I attached to the runtime map generator:

using UnityEngine;
using DunGen;

public class TileMapPrefabFix : MonoBehaviour {

   void OnEnable() {
        GetComponent<RuntimeDungeon>().Generator.OnGenerationStatusChanged += Generator_OnGenerationStatusChanged;
    }
    void OnDisable() {
        GetComponent<RuntimeDungeon>().Generator.OnGenerationStatusChanged -= Generator_OnGenerationStatusChanged;
    }

    private void Generator_OnGenerationStatusChanged(DungeonGenerator generator, GenerationStatus status) {
        if (status == GenerationStatus.Complete) {
            tk2dTileMap[] tileMaps = generator.Root.GetComponentsInChildren<tk2dTileMap>();
            foreach (tk2dTileMap tileMap in tileMaps) {
                tileMap.ForceBuild();
            }
        }
    }
}

2
Not sure what is up here, but it's infuriating. I'm using 2D Toolkit 2.5.5 with Unity 5.3.1f1. Here are the steps to reproduce:
  • Start a new 2D (or 3D) project
  • Open Asset Store and import 2D Toolkit
  • Create a tk2dcamera in the Hierarchy tab
  • In the Project tab, click Create -> tk2d -> Sprite Collection
  • Give it a name (say, Tiles.prefab)
  • Select the Sprite Collection in the Project Tab
  • Click Open Editor in the Inspector
  • Change anything in the Settings of the Sprite Collection, say Physics 3D to Physics 2D or the PPM
  • Click Commit
  • Watch Unity close immediately with no errors
  • Cry  :'(

Pages: [1]