Modding with Burst – BB – Update 13

close upModding with Burst – BB – Update 13close up

Posted: March 2, 2025

Last Updated: March 2, 2025

Modding with Burst – BB – Update 13

Timeframe: February 19, 2025 – February 25, 2025

!!! Jump to Visual Demos !!!

Welcome. This update is kind of short because a lot of the information is offloaded to other pages and the topic is similar to last time: modding.

HIGHLIGHTS:

Prefab Render Fixes:

I added a couple more prefab Bullets (orange, yellow, green, purple) to the base game. These bullets shared sprites with some of my demo Enemy and Player prefabs, which caused some issues with my setup. I have an NSpriteAtlasSystem whose job it is to go through an existing scene and change all sprites to use the same texture. In doing so, I deregister their prior texture ID. Then in the SpriteAssetManager, I iterate all the prefab sprites, essentially doing the same thing. However, if a prefab sprite has the same sprite as one in the existing/starting scene, then its ID has already been deregistered, so I cannot retrieve it from the RenderArchetypeStorage. To fix this, I just keep a cache of deregistered textures in the RenderArchetypeStorage that I can query later in the SpriteAssetManager.

Performance Improvements:

When profiling the game build, there were spikes in frame time that followed patterns. These spikes seemed to occurred when a firing point would fire as well as every 0.5s. Looking further, this was due to TextMeshPro’s TMP_Text box making long calls to GenerateText. This pointed me to an inefficiency in some text render process. After some searching, I found that the debug information text box was causing these long generation times, so I tackled it with these changes:

  • Enable/Disable: Added some logic to hard-enable/disable the debug information canvas and InGameBuilder UI by setting their GameObjects to be inactive.
  • DebugOverlay: Rendering all debug information in a single textbox seemed to be mitigated by having the same text split across multiple text boxes. Now, I process the incoming text a bit more, and split the incoming string by two newlines, creating a new textbox for each chunk of text found this way. I also check if the text is the same before updating.

Modding Modifications:

I immediately took a mulligan on my mod system and added burst support, a folder system, and changed some of the setup. I also have a helpful example GitHub repo for a general modding setup using Unity ECS. Check it out if you are interested in adding modding into your own ECS-based game!

  • Folders: Mods now come in folders. If a folder has a manifest.json file, then it is a mod folder. There are several options included in the mod manifest:
    • Name: What is the mod called.
    • Version: Mod version.
    • UseAllDLLs: Whether all DLLs in the folder and subfolder should be loaded by default.
    • IncludedDLLs: If not including DLLs by default, specify which ones to include.
    • ExcludedDLLs: If including DLLs by default, specify which ones to exclude.
    • BurstDLLs: Which DLLs are burst-generated and should be loaded in a special way.
    • Enabled: Whether the mod should load at all.
    • ModPriority: Higher priority mods load first.
  • ModLoader: Now a static class that does the mod loading. I was over-complicating things before.
  • ModManifest: Represents a single mod folder. Can perform some validation to ensure the mod is set up properly and gather relevant DLLs to be loaded in specific ways by the ModLoader. Can now gather burst-generated DLLs.
  • ProjectManifest: Represents all the mods for the project. Kind of just an interface between all the ModManifests and the ModLoader.
  • Loading: I forego the AttachToEntityClonerInjection method from last update because I found that just decorating LoadModDLLs with RuntimeInitializeLoadType.BeforeSplashScreen works for this project.

Video Demos

Rainbow! Uses a test gravity mod and the new bullet colors.