Creating Your First Plugin

Create your first BepInEx plugin and learn how a PvZ Fusion mod is structured.

AuroraModder2 min read
ObjectivesGoal-setting

What you'll build

By the end of this lesson, you will:

  • Create a BepInEx plugin project
  • Understand the basic plugin structure
  • Compile a DLL
  • Load your first mod in PvZ Fusion
PrerequisitesGating

Before you start

You should already have:

  • PvZ Fusion installed
  • BepInEx installed
  • CustomizeLib installed
  • Visual Studio 2022 installed
IdeaInsight

What is a plugin?

A plugin is a DLL loaded by BepInEx when the game starts.

Plugins allow developers to modify the game, add new content, and create entirely new mechanics.

WarningCaution

Do not modify game files directly

Mods should be loaded through BepInEx plugins.

Avoid modifying game files directly whenever possible.

StepsProcedure

Creating the project

  1. Open Visual Studio 2022.

  2. Create a new project.

  3. Select:

Class Library

  1. Choose a project name.

  2. Create the project.

StepsProcedure

Adding references

Your project needs references to BepInEx and the game's assemblies.

These references allow your code to interact with PvZ Fusion.

StepsProcedure

Creating your first plugin

Create a class that inherits from BaseUnityPlugin.

This class will be loaded automatically by BepInEx when the game starts.

ExampleSample

Basic plugin structure

The following code shows the smallest possible BepInEx plugin.

Plugin examplecsharp
[BepInPlugin("com.yourname.firstmod", "My First Mod", "1.0.0")]
public class MyFirstMod : BaseUnityPlugin
{
}
StepsProcedure

Building the plugin

Build the project using Visual Studio.

The generated DLL will be located inside the build output folder.

StepsProcedure

Installing the plugin

  1. Locate the generated DLL.

  2. Open:

BepInEx/plugins

  1. Copy the DLL into the plugins folder.
StepsProcedure

Testing the plugin

Launch PvZ Fusion.

If everything was configured correctly, BepInEx will load your plugin automatically.

Recap / BravoCelebration

First plugin completed

Congratulations!

You have created and installed your first BepInEx plugin.

You are now ready to start writing code and creating real PvZ Fusion mods.