Skip to content

Unity Tutorial

SpaceCat edited this page Aug 19, 2024 · 7 revisions

Important

(THIS IS WORK IN PROGRESS , CURRENTLY SETTING UP LINKS AND INFORMATION , THANKS FOR WAITING)

Requirements

Windows : You can find this from the Game Executable,

Properties > Details > File Version

  • !It's important that you try to use the same unity version of the Game *These versions are subject to change
    • Lethal Company Uses 2022.3.9f1
    • Content Warning Uses 2022.3.10f1
    • Bomb Rush Cyberfunk Uses 2021.3.20f1
    • Valheim Uses 2022.3.17f1

New Project

Once your Unity Editor is installed, Create a New Project

  • !Make sure you verify the Rendering engine a game uses
    • Lethal Company Uses HDRP (High Definition 3D)
    • Content Warning Uses URP (Universal 3D)

Check in with your modding community for any additional information.

Using UCustomPrefabs

1) Import UCustomPrefabs

In Unity Start by Importing your Game's Package : [Packages Here]

Press IMPORT

And Verify there is a "UCustomPrefabs" folder

2) Creating a Template Prefab

Start by Creating a new Prefab

  • Assets > Create > Prefab

You may name this prefab what ever you'd like.

2.1) Understanding the Hierarchy

** *** (TECHNICAL INFORMATION, YOU CAN SKIP THIS) *** **

Once your Prefab is created,

The Top 'GameObject' Will be exclusively for "Custom Actions"

Any Children will be considered the "Prefab Template"

There can be multiple and will only appear when in determined state at runtime.

This allows individual parts to be loaded independently.

At Runtime, Only children objects with "PrefabTemplate" will be considered.

3) CustomActions

"CustomActions" are the name of the extra features you may want to include.

!!!IMPORTANT!!!

If you are here for Content Warning You will need the Content Warning for this EXAMPLE.

Otherwise, for any other Game check in with your modding community or any provided information in the main wiki page

The general process will be the same regardless, So feel free to continue reading

For this example, I will show the Content Warning approach.

  1. Select the First GameObject

  1. Add a Component, "CW_RigHelper"

  1. Add "CW_ShaderFix" As Well.

It should look something like this.

4) Creating a Model Rig

Now we can add in a model to use.

Preferably import a FBX and set it up for Humanoid.

(I will not include a tutorial for this At the moment)

(you could follow this example from Bunya's ModelReplacement API where it says "You can now import your 3D model" up to "Once finished click Apply and exit." )

  1. Drag and drop your model into the Hierarchy Panel to ensure it's placed at zero/default position.

I Included a model from Mixamo in the UCustomPrefabs > Resources > Models Folder

It's important the model is centered otherwise it will be misaligned.

  1. Select the Model

  1. Add Component "RigBuilder" (Make sure you DONT use "RigBuilderTemplate" , which is different)

  1. Add Rig Template

I included a template with the Content Warning Example, Which will help setup the required bones.

It should be located in UCustomPrefabs > ContentWarning > Templates

  1. Finally Just "Build Rig"

If everything went correctly, Your Console should look like this >

If 0 or 1 "Bones" are attached, Check if your model is actually Humanoid, And has the Animator component in it already.

4.2) Adding A "Template"

In order for UCustomPrefabs to recognize the template, you must then add the "Prefab Template" Component.

keep the settings as default,

the "default" state is the initial "template" that gets loaded.

5) Building AssetBundle

I included a little tool to help make the process easier.

  1. Add a AssetBundleHelper

Assets > Create > UCustomPrefabs > AssetBundleHelper

  1. Select and Name The AssetBundle Helper created

  1. Fill In Information, Add your Prefab to the Templates List.

  1. Finally, Build the AssetBundle, This will create a new file in Assets > AssetBundles , the correct file should be the name you put in "File Name"

6) Using In Game

Currently for Content Warning,

Any folder inside of the BepInEx plugins folder that contains a txt file called "ucustomprefabs.templates.txt" will search for compatible templates.

Place your created assetbundle in this folder and it will automatically import it as a template.

(It's IMPORTANT you use the provided AssetBundle method , as additional information is generated as a JSON txt file)