Skip to main content

Updating TileFabs

One of the goals of this system is rapid iteration.

One final annoyance comes from the fact that if you change anything on a Tilemap after you've archived it the Bundle or TileFab needs to be recreated. The TpFabUpdater component can be used to update Bundles in a few seconds!

TpFabUpdater: new EXPERIMENTAL Component.

Briefly:

  • Add to a Tilemap's parent GRID.
  • Add asset references for a TileFab or a ChunkZoneSelector.
    • If both are provided, the TileFab asset referenced in the Selector is used.
    • When using the Layout system use the Selector because that ensures that the proper bundles are updated.
  • Used to update a referenced TileFab's BUNDLES from the child Tilemaps of the GRID.
  • See the component's code for more info. VERY HANDY for iterative level creation using TileFabs.
  • IMPORTANT NOTE: bundles created with from a multiple-selection PICK are incompatable with FabUpdater

Details:

  • A component that can be added to a GRID's GameObject for updating a Tilefab's Bundles.
  • Provide a Selector and/or TileFab reference.

Use:

  • Create a TileFab normally via menu commands or from Painter Grid Select panel.
  • When you want to update this TileFab due to changes in the Tilemap you don't need to follow that process again.

Add this TpFabUpdater component to the parent GRID of the TileMaps and drag the created TileFab asset reference into the 'TileFab' field. If you've created a Selector for the Layout system you can use that instead. If this component sees both it will always use the Selector (which has a ref to the TileFab).

One reason to use the Selector is to ensure that the same TileFab that the Selector is using is actually the one that you want to modify.
When either field is not-null, an 'Update' button will appear. Clicking that will update selected TileFab's bundles with the current set of tiles using the GridSelection size and position embedded in the TileFab. If there are TilePlus tiles on the Tilemap the existing saved and locked tile assets are removed (they are sub-objects to the Bundle asset) and replaced with new locked tile assets.
The TileFab is NOT affected at all. The Selector isn't affected either. The Bundles are affected: those which have been changed have new timestamps as well as new internal data baed on the archived tiles and prefabs.

BACK UP YOUR ORIGINAL BUNDLES JUST IN CASE

Specific error messages may appear in the component editor:

  • Duplicate Tilemap names: the connection between TileFabs and actual Grid+ChildTilemaps uses the Tilemap name to locate the tilemap.

Unlikely:

  • If the Grid+Maps are part of a Prefab. Unpack the prefab first.
  • If the Scene View is a Prefab Editing context.

Fields:

  • TileFabAsset is a ref to the TileFab - which is mostly a list of the child TileBundles.
  • Selector is an optional ref to the Selector used by the layout system

CONTROLS:

  • Confirm: if checked, a confirmation dialog is shown before anything is affected.
  • Update Prefab - if this is checked, all the prefab asset references in the Bundle are updated.
    • Note that all prefabs which are chilren of the Tilemap's GameObject are stored as asset references along with positioning data. The prefabs aren't affected.
    • Similarly, normal Unity tiles are stored as a single reference along with all positioning, color, flags, and transform data for each Unity tile.
    • Color, flags, and transform data are stored in indexed lookup tables since they are often repeated.
      • for example, Color is usually White and transform is usually Matrix4x4.Unity.
      • this approach matches the serialization approach for the Tilemap component.

Under the checkboxed is a (hopefully scrollable) list of the child tilemaps of this Grid which have Bundles that correspond to the referenced TileFab.
Check boxes allow you to choose which Bundles to update.

  • These can be all toggled ON or OFF or have their states toggled using buttons at the bottom of the component's editor.

The UPDATE button launches the update process with an optional confirm dialog.

ALSO IMPORTANT: if you have an existing TileFab and a corresponding set of bundles and THEN you add a new Tilemap to the Grid you have to go thru the TileFab creation process again. That's because there's no bundle which corresponds to the the new Tilemap: nothing exists that can be updated.

SIMLARLY: if you have several Tilemaps as children to a parent Grid but some of the Tilemaps have no tiles when you first create a TileFab AND then you add tiles to the previously empty Tilemaps then you need to create the TileFabs again. That's because the TileFab won't have any reference to the empty Tilemaps - empty Tilemaps aren't archived so there's nothing to update. You'll notice that the Editor for this component only shows checkboxes for Tilemaps that are currently archived.

Compatability with older assets:

IMPORTANT: Using this feature requires a new field in TpTileBundles with the original GridSelection so that the position of the archived area can be determined.
In older Bundles this will exist but the value will be invalid and you'll get an error in the console.

FIX: create new bundles OR manually edit that field (OriginalTilemapBoundsInt) appropriately.

The size of that field should be the same as 'TilemapBoundsInt' but the position should be set correctly, which can be hard to do.