1 of 8

Tower defense kit for Unity

Adrián Kormoš

2 of 8

Quick overview

  • Kit for making Tower defense games easier
  • Logic for towers, spells, enemies
  • Tile-based levels

  • Multiple level support
    • How to create a new level?

3 of 8

How to create a new level?

  • Level
    • Scene with game objects
    • Level Configuration – Scriptable Object

  • Create a scene and put everything one by one
    • Too cumbersome

  • Save the scene objects as prefabs and put them into new level
    • Issues with some dependencies (need to re-couple some objects)
    • Can we automate that?

4 of 8

My solution

  1. Create a template with a list of prefabs we want in a new level
    • Scriptable Object
    • Manual step

  • Create a new Scene and Level Configuration
    • Manual step – can we automate that?

  • Import Prefabs into level
    • And fix the broken dependencies
    • Automatic step

5 of 8

Issues with dependencies

  • One scene object needs a reference to another scene object
  • Will get deleted/nulled when saving it as a prefab

6 of 8

My solution for the issue

  • Create an abstract Component - PostImportComponent
    • Class inheriting MonoBehaviour
    • Method for finding and coupling dependencies
      • PerformPostImport
    • Method for getting a component to mark as dirty
      • GetTargetComponent

  • Objects will have concrete components
    • Inheriting PostImportComponent

7 of 8

Overall solution

  • New window for importing prefabs
  • Will create new scene objects from prefabs in the template
    • And remove the (Clone) suffix
  • Will go through each PostImportComponent to re-couple objects

8 of 8

Thanks for watching

Any questions?