Repository navigation
Creating your first mod
DipCrai edited this page Jun 27, 2024
·
10 revisions
- Open WorldBox directory
- Open or create folder named
Mods - Create folder with your project name
- Create
mod.jsonfile and paste this template into it
{
"ModName": "",
"Author": "",
"Description": "",
"Version": "",
"Scripts": [],
"EntryPoint": ""
}- In field called
ModNameenter the name of your mod - In field called
Authorenter author name of your mod - In field called
Descriptionenter description of your mod - In field called
Versionenter version of your mod - In field called
Scriptslist all files in your mod directory with extension.cs
Example: "Scripts": [ "AAA.cs", "BBB.cs", "CCC.cs", "Folder name\\ScriptName.cs" ]
Make sure that \ is replaced with \\, otherwise the game will throw an error. Or use / instead of \
- In filed called
EntryPointenter name of class that contains method calledMain
Example "EntryPoint": "NamespaceName.ClassName"
You can also create folder called dependencies that contains your mod dependencies (dll files)
Here is an example of the file that should result in the end:
{
"ModName": "Sample mod",
"Author": "DipCrai",
"Description": "Just sample mod",
"Version": "1.0",
"Scripts": [ "Mod.cs", "Debugger.cs", "Utils.cs" ],
"EntryPoint": "SampleMod.Mod"
}- Create file with name specified in the
mod.jsonfile - Add necessary usings
- Create namespace with namespace name specified in the
mod.jsonfile (NamespaceName.ClassName) - Add class with class name specified in the
mod.jsonfile (NamespaceName.ClassName) - In class create method called
Main
After this steps your C# file should look like this:
using UnityEngine;
namespace NamespaceName
{
public class ClassName
{
public static void Main()
{
//This method is the entry point.
}
}
}Here is an example of the code that should result in the end:
using UnityEngine;
namespace SampleMod
{
public class Mod
{
public static void Main()
{
Debug.Log("Init Sample Mod");
GameObject sampleObject = new GameObject("Sample Object");
sampleObject.AddComponent<SampleComponent>();
}
}
public class SampleComponent : MonoBehaviour
{
private void Start()
{
Debug.Log("Sample component");
}
}
}