Hello Guest

Author Topic: Error when creating a new TileMap  (Read 5866 times)

Afro-Ninja

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 62
    • View Profile
Error when creating a new TileMap
« on: November 20, 2013, 06:39:20 am »
Unity 4.3, 2dtk 2.3.0

I create a new tilemap (with no map data or editor data or sprite collection set) and get the following error:

NullReferenceException: Object reference not set to an instance of an object
tk2dTileMap.Awake () (at Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMap.cs:107)
UnityEngine.GameObject:AddComponent()
tk2dTileMapEditor:Create() (at Assets/TK2DROOT/tk2dTileMap/Editor/tk2dTileMapEditor.cs:1267)

tilemap seems to behave fine, just not sure what causes this.
thanks!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Error when creating a new TileMap
« Reply #1 on: November 20, 2013, 11:30:48 am »
Its a bug, but should be harmless. Will be fixed in the next version.

Afro-Ninja

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 62
    • View Profile
Re: Error when creating a new TileMap
« Reply #2 on: November 20, 2013, 05:48:27 pm »
got it, thanks. one other question:
what is the proper way to 1:1 a tilemap? through the regular unity inspector properties?

After clicking 1:1 on my sprites I've found that the correct scale for the camera is roughly 5.77.
The tilemap however has no 2dtk 'scale' property like regular sprites do, so I just set the gameobject scale to 5.77.

I assume this is fine but just wanted to make sure I didn't miss anything.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Error when creating a new TileMap
« Reply #3 on: November 20, 2013, 05:58:55 pm »
All you need to do is set up your tk2dCamera with the same pixels per meter setting as the sprite collection. No need to click anything to make it pixel perfect.

Afro-Ninja

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 62
    • View Profile
Re: Error when creating a new TileMap
« Reply #4 on: November 20, 2013, 09:03:01 pm »
Ah, I don't use the tk2d camera. I started using a regular perspective cam + ortho sorting back when the tk2d cam wasn't able to handle perspective and zoom. I also make use of an AspectRatioEnforcer that modifies my main cam. I'm afraid that switching to tk2d cam now will break my current solution.

are you saying that if I place a tk2d cam on the stage and correctly set the ppm, any future tile maps I create will start at the right size?

or do I just need to set the ppm for the sprite collection that contains my tiles, and the tiles will appear at the right size?

Defaultly, my camera sits at Z -10, while everything else is at Z 0. The documentation talks about the use of pixels per meter, but I've never been 100% how to actually calculate the ppm that I need.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Error when creating a new TileMap
« Reply #5 on: November 20, 2013, 09:44:32 pm »
If you use a perspective camera then you'll have to scale manually. Its easy though, create a sprite from that tile map, click 1:1 to find out what it needs to be, then manually enter the numbers into the tile map component's localScale. This isn't automatically implemented for a few reasons, but if you know what you're doing you should be fine.

Afro-Ninja

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 62
    • View Profile
Re: Error when creating a new TileMap
« Reply #6 on: November 20, 2013, 10:10:16 pm »
ok, that's what I've been doing. just wanted to make sure it was an acceptable way.
Since I'm doing it this way is it safe to say that my 'ortho size 1 and target height 720' don't really affect anything? and I don't need to worry about them?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Error when creating a new TileMap
« Reply #7 on: November 20, 2013, 10:37:53 pm »
You're right, you don't need to worry bout it.