Runtime Tile Demo

Sample scene showing how to create a city builder based on tiles.

Installation

  • Add the RUNTIME_ROAD scripting define to the Player Settings of the project.

    _images/runtimeRoadInstall.png
  • Open the RuntimeTileRoad Demo to get started.

Tile Prefab

How To Create

  1. Open your prefab with your tile.

    _images/tileCreation1.png
  2. Create initial Road segment in the Prefab stage.

    _images/tileCreation2.png
  3. Adjust segment type, number of lanes, lane width and rotation to suit your tile.

    _images/tileCreation3.png
  4. Traffic nodes & Pedestrian nodes entrances/exits should overlap at the same position for all segments so that they can connect to other tiles at those positions.

    _images/tileCreation3_1.png

    Source tiles example.

    _images/tileCreation3_2.png

    Example of overlap between traffic nodes and pedestrian nodes (Traffic node arrows & blue pedestrian node should overlap perfectly)

  5. Add a RuntimeSegment component to the parent of the tile.

    _images/tileCreation4.png
  6. If you have made further changes to the road segment, press Bake in the RuntimeSegment to bake the data.

  7. The next steps are optional if you are using your own placement solution.

  8. Add a RuntimeRoadTile component to the parent of the tile.

    _images/tileCreation5.png
  9. Assign a Tile Settings to the RuntimeRoadTile.

    _images/tileCreation6.png
  10. Select Prefab type according to the shape of the tile (custom types for custom shapes).

    _images/tileCreation7.png
  11. Select the direction of the connections if you want to use automatic tile replacement (currently only works for 1x1 tiles).

    _images/tileCreation8.png

    Connection example (circles on scene show direction)

  12. Select Recalculation type, if you want to use automatic tile replacement.

    _images/tileCreation9.png
  13. Add a RuntimeRoadTileView component & assign it to the RuntimeRoadTile.

    _images/tileCreation10.png
  14. The next step is to assign it to a Tile preset according to its Prefab type.

    _images/tileCreation11.png

Preview Icon

To create a Preview icon for the Prefab tile, follow these steps:

  • Select from Spirit604/CityEditor/Window/Prefab Preview Saver the toolbar context menu.

    _images/preview1.png
  • Drag & drop create tile prefabs into the list field.

    _images/preview2.png
  • Adjust the camera position to adjust the Preview icon.

    _images/preview3.png
  • Press Create Button.

How To Place

  • If you are using your own placement logic, use this sample code:

    [SerializeField] private RuntimeSegment runtimeSegmentPrefab;
    
    private void Place(Vector3 position, Quaternion rotation)
    {
            var runtimeSegment = Instantiate(runtimeSegmentPrefab, position, rotation);
            runtimeSegment.PlaceSegment();
    }
    
  • Make sure RuntimeRoadManager is on the scene.

Tile Settings

Contain settings for the size of a single cell.

How To Create

  • Select from Spirit604/RuntimeDemo/Tile Settings the project context.

    _images/tileSettings1.png

Where Is Used

  • RuntimeRoadTile.

  • GridBoundsBase.

  • TileGrid.

Tile Preset

How To Create

  • Select from Spirit604/RuntimeDemo/Tile Prefab Data Container the project context.

    _images/tilePreset1.png

How To Assign

  • Select TileFactory in the scene.

    _images/tilePreset2.png
  • Assign preset to the TileFactory.

    _images/tilePreset3.png

Structure

_images/structure1.png
  1. Camera : sample camera of Tile demo [optional].

  2. TileGameUI : sample UI manager of the scene, used by TileGameManager. [optional, can be replaced by an implementation of `TileGameUIBase`].

  3. CullPoint : Cull point of the scene [required].

  4. CameraFollowObject : follow & aim point of the Camera, controlled by CameraMover [optional].

  5. CameraMover : controls the movement of the aim point of the Camera [optional].

  6. MapBounds : limits of the movement of the CameraFollowObject, used by CameraMover [optional].

  7. Input : user input of the tile game, used by TileGameManager [optional, can be replaced by an implementation of `TileGameInputBase`].

  8. TileGameManager : main sample tile manager, which controls all sample placement logic [required, if you are using RuntimeTileRoad demo scripts].

  9. RuntimeRoadTilePlacermanager which responsible for tile layout on the scene [required, only if you are using RuntimeTileRoad demo scripts].
    • TileGrid : map of tiles added to the scene. [optional, can be replaced by an implementation of `TileGridBase`].

    • GridSceneView : grid display on the scene [optional, can be replaced by an implementation of `GridSceneViewBase`].

    • PreviewService : display a preview of an object on the scene before it is created [optional, can be replaced by an implementation of `PreviewServiceBase`].

  10. RuntimeRoadManager : manager that converts RuntimeSegment road into an entity road graph. [required].

  11. GridBounds : limit of the map of cells available for the tile prefabs, used by RuntimeRoadTilePlacer [optional, can be replaced by an implementation of `GridBoundsBase`].

  12. TileFactory : factory containing all the Tile presets, used by TileGameManager [optional, can be replaced by an implementation of `TileFactoryBase`].

  13. Tiles : tile parent of the tiles, used by RuntimeRoadTilePlacer [optional].

  14. Plane : plane of the scene [optional].