A1. Setting up the Unity Editor

Updated 2 weeks ago

If you have a Code/CSharp project setup for this then you only need to do a couple extra things.

CodeRebirthLib supports registering mods in the editor. To register automatically you need to:

  • make your main bundle have the extension .crmod
  • contain a ModInformation ScriptableObject and a ContentContainer ScriptableObject, both in the same main bundle that has teh extension .crmod

Expected structure is:

plugins/
-> yourmod.crmod
-> Assets/
-> -> my_contentdefinition_bundle

The nice thing is that this structure gets automatically created by the automatic zip package from the Mod Information ScriptableObject if you have the CodeRebirthLib.Editor.dll in https://github.com/TeamXiaolan/CodeRebirthLib/releases/tag/0.9.0 placed in the Assets/Editor in your UnityProject. (You can create that folder yourself if it does not exist). This structure is also automatically created for you when you use the C# Template that CodeRebirthLib provides.

Setup - Extra Notes for the Editor portion

  • The way you should be setting up your project in the editor is very simple, you need to go through this path after patching: Assets/LethalCompany/Mods/plugins/ and create a folder there that's just your mod's name, so something like CodeRebirth.
  • From there create another folder inside that and call it dependencies, this is where you'll go to thunderstore and manually download CodeRebirthLib and all its dependencies and just drag them in there so it should look something like this:

Dependencies Image

  • Don't forget to go to the CodeRebirthLib dll and untick Validate References so it doesn't check for soft dependencies like LethalConfig or WeatherRegistry.

  • Also if you ever need to update your unity project to the latest lethal version, you can just make a new unity project, patch that one with the latest lethal version, and drag your ModNameFolder into the plugins folder like how it is in the previous unity project you had, that's it.

  • Finally, if using CRAssetBundleBuilder (which is recommended), set your bundle output path to the res folder in your project if you have a CSharp/Code project, and if not, just make an Assetbundles folder next to Dependencies folder and put them all in there.

[!NOTE] If you use a vanilla asset in your unity project into your mod, make sure to move it somewhere in your own mod's folder, so that when you do update to latest lethal version, it doesnt get lost from accidently deleting it.