Project Setup - BunyaPineTree/LethalCompany_ModelReplacementAPI GitHub Wiki

This page will be left in for now, but note that it is completely outdated given the ability to generate mods using the SDK

Setting Up A New VS Project

It is assumed that you already have an assetbundle built from the unity workflow

  • Start by cloning the Miku example mod or the entire repository

  • Thanks to the efforts of linkoid the majority of the project references should resolve automatically if your lethal company is at the default location of C:\Program Files (x86)\Steam\steamapps\common\Lethal Company\. If not enter your mod's project (presently HatsuneMikuModelReplacement.csproj) and change the LethalCompanyPath to the correct location.

  • Download the latest version of ModelReplacementAPI.dll from the releases page, or the github build folder and place it next to HatsuneMikuModelReplacement.csproj. Alternatively, if you cloned the entire repository to modify ModelReplacementAPI.dll yourself, uncomment the commented region in HatsuneMikuModelReplacement.csproj and delete the ModelReplacementAPI.dll reference.

  • Replace the files mbundle and mbundle.manifest with your own assetbundle and manifest, then enter HatsuneMikuModelReplacement.csproj and replace the below names with your assetbundle's names.

 <ItemGroup>
   <None Remove="mbundle" />
 </ItemGroup>
 <ItemGroup>
   <EmbeddedResource Include="mbundle" />
 </ItemGroup>

Finally enter Plugin.cs and replace the below name as well. It is important that the names entered here are the same, otherwise Assets.PopulateAssets() will not find your embedded assets.

public static string mainAssetBundleName = "mbundle";
  • To prevent possible bepinex conflicts rename all instances of meow.MikuModelReplacement to your own mod's GUID, and preferably the other mod strings as well, but those aren't necessary.

  • Enter BodyReplacementMiku.cs and delete the contents of AddModelScripts() if your project does not have DynamicBones. AddModelScripts() is a model specific method that exists to programmatically add scripts that you could not add through the assetbundle. If you don't have any scripts to add to your model, you can delete the method entirely.

  • modify below such that it uses your model replacement prefab's name, without path or extension. This can be easily found in your assetbundle's manifest file. If you have any other modifications to make to your prefab before it is instantiated into the game (such as modifying textures or whatnot) it can also be done here.

protected override GameObject LoadAssetsAndReturnModel()
{
    //Replace with the Asset Name from your unity project 
    string model_name = "HatsuneMikuNT";
    return Assets.MainAssetBundle.LoadAsset<GameObject>(model_name);
}
  • With luck, at this point all that is left is to build your project and place it and ModelReplacement.dll in your bepinex plugins folder. I personally recommend that you use a third person mod or UnityExplorer for its freecam to inspect your model in game for flaws.

Note that this walkthrough and the Miku example mod embeds the assetbundle into your assembly. It is also an option to load the assetbundle as a separate file or use LC_API's bundle loader. Finally, don't forget to change the numerous references to Miku to your own mod's identity.

⚠️ **GitHub.com Fallback** ⚠️