GTFO Modding
  • 🏠Home
    • 🫂Contributing
  • Guides
    • 📖The Complete Newbie Guide
    • The Newbie Level Guide
      • Isolating a level
      • Editing rundown and level metadata
      • Adding and editing zones
      • Editing warden objective
      • Adding a secondary sector
      • Final datablocks version
    • The Newbie Git Guide
    • 👶Your First Plugin
      • Setting up Visual Studio Community
      • Creating a C# class library project
      • Writing a Plugin class
      • Compiling for release
      • Creating a Patch class
      • Patching in slightly more detail
    • 🎹Adding Custom Audio
      • Project Setup
      • Adding Sounds into Wwise
      • Creating a Sound Event
      • Creating a SoundBank
      • Using SoundBanks in GTFO
    • ⛏️Datamining
      • Audio files
      • Export asset files from GTFO
      • Import asset files to Unity
      • Fixing Unity errors after importing
    • Introduction to Errors
    • Modded GTFO on Linux
    • Enabling MTFO Hot Reload
    • VS Code Tips
    • Creating Custom Weapons
    • External Guides
  • Reference
    • Datablocks
      • Main
        • Archetype
        • BigPickupDistribution
        • ChainedPuzzle
        • ComplexResourceSet
        • ConsumableDistribution
        • Dimension
        • EnemyBalancing
        • EnemyBehavior
        • Enemy
        • EnemyDetection
        • EnemyGroup
        • EnemyMovement
        • EnemyPopulation
        • EnemySFX
        • ExpeditionBalance
        • FlashlightSettings
        • FogSettings
        • GearCategory
        • Gear
        • Item
        • ItemFPSSettings
        • LevelLayout
        • LightSettings
        • MeleeAnimationSet
        • MeleeArchetype
        • Player
        • PlayerOfflineGear
        • Recoil
        • Rundown
        • SurvivalWavePopulation
        • SurvivalWaveSettings
        • Text
        • VanityItemsTemplate
        • WardenObjective
        • Weapon
      • Rarely Edited
        • Artifact
        • ArtifactDistribution
        • ArtifactTag
        • Atmosphere
        • BoosterImplantCondition
        • BoosterImplantEffect
        • BoosterImplantTemplate
        • ChainedPuzzleType
        • Clouds
        • CustomAssetShard
        • EnvironmentFeedback
        • Feedback
        • GameSetup
        • GearCategoryFilter
        • GearFlashlightPart
        • GearFrontPart
        • GearMagPart
        • GearMeleeHandlePart
        • GearMeleeHeadPart
        • GearMeleeNeckPart
        • GearMeleePommelPart
        • GearPartAttachment
        • GearReceiverPart
        • GearSightPart
        • GearStockPart
        • GearToolDeliveryPart
        • GearToolGripPart
        • GearToolMainPart
        • GearToolPayloadPart
        • GearToolScreenPart
        • GearToolTargetingPart
        • ItemMovementAnimation
        • ItemPart
        • MarkerGroup
        • MeleeSFX
        • MiningMarker
        • MLSArrayDescriptorReference
        • MusicState
        • PlayerDialog
        • ServiceMarker
        • StaticSpawn
        • TechMarker
        • TextCharacterMeta
        • VanityItemsGroup
        • VanityItemsLayerDrops
        • WeaponAudio
        • WeaponMuzzleFlash
        • WeaponShellCasing
      • Unused
        • Commodity
        • EffectNode
        • EventSequenceAction
        • EventSequence
        • ExtractionEvent
        • FogScenario
        • GameplayTrailer
        • GearDecal
        • GearPalette
        • GearPattern
        • GearPerk
        • LevelGenSettings
        • Loot
        • Recepie
    • Nested Types
      • AbilityData
      • ActiveEnemyWaveData
      • AltitudeData
      • AnimHash
      • ArtifactLayerData
      • ArtifactZoneDistribution
      • AssetData
      • BigPickupSpawnData
      • BoosterImplantEffectInstance
      • BuildLayerFromData
      • BuildSeedData
      • BulkheadDoorPlacementData
      • ChainedPuzzleComponent
      • ConsumableSpawnData
      • CustomTerminalCommand
      • DescriptiveData
      • DialogActorSettings
      • DialogDramaFilter
      • DialogLine
      • DialogStructure
      • DialogStructureHolder
      • DimensionData
      • DimensionInExpeditionData
      • DOFSettingsData
      • DumbwaiterPlacementData
      • EffectNodeListData
      • EffectNodePrefabData
      • EnemyGroupCompositionData
      • EnemyRoleData
      • EnemySpawningData
      • ESA_EnemyWave
      • ESA_FogSettings
      • ESA_Lights
      • ESA_PostEffect
      • ESA_Sound
      • EventSequenceActionListComponent
      • ExpeditionData
      • ExpeditionIndex
      • ExpeditionInTierData
      • ExpeditionZoneData
      • FeedbackAudioCompData
      • FeedbackEffectCompData
      • FunctionPlacementData
      • GameEventSound
      • GameplayTrailerDirectorAction
      • GearArchetypeData
      • GearCategoryFilterData
      • GearDropPeriodData
      • GearPartAlignData
      • GearPartAlignPriority
      • GearPartGeneralData
      • GearPerkModifierData
      • GearPicker
      • GearSightPartProperties
      • GearSpecialPerkData
      • GeneralFogDataStep
      • GenericEnemyWaveData
      • HealthData
      • ItemPartData
      • LayerData
      • LayerDropData
      • LanguageData
      • LevelEventData
      • LevelEventNoiseData
      • LevelEventSoundData
      • LevelEventWardenIntelData
      • LevelGenConfig
      • LightCategorySetting
      • LinkedSlaveModelData
      • LocalizedText
      • Loot
      • MarkerComposition
      • MarkerDataCommon
      • MeleeAttackData
      • MinMaxValue
      • ModelData
      • MusicEventData
      • MusicEventDataConditional
      • MusicEventDataTimed
      • MusicSwitchData
      • MusicSwitchDataOnCustomCue
      • MusicSwitchDataTimed
      • ProgressionPuzzleData
      • ReactorWaveData
      • ReactorWaveEnemyData
      • ResourceData
      • RundownStorytellingData
      • RundownStorytellingVisualData
      • RundownTierProgressionData
      • SpecialExpeditionOverridesData
      • SpecificChainPuzzleSpawnData
      • SpecificPickupSpawnData
      • SpecificTerminalSpawnData
      • StaticEnemyData
      • StaticSpawnDataContainer
      • StaticSpawnPrefabDistancePair
      • TerminalLogFileData
      • TerminalOutput
      • TerminalPlacementData
      • TerminalStartStateData
      • TerminalZoneSelectionData
      • TierVisualData
      • TimingData
      • TypeAndGeneralData
      • VanityItemsDropData
      • Vector3AnimationCurve
      • WardenObjectiveEventData
      • WardenObjectiveLayerData
      • WeaponAnimSequenceItem
      • WorldEventConditionPair
      • WorldEventFromSourceData
      • ZonePlacementData
      • ZonePlacementWeights
    • Enum Types
  • Mods Documentation
    • Noteworthy Mods
    • Documentation
      • StealthAdjustment
      • DynamicCustomCombatMusic
      • ConfigurableGlobalWaveSettings
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
Export as PDF
  1. Guides
  2. Your First Plugin

Writing a Plugin class

The following Plugin class will allow BepInEx to load and handle your compiled assembly as a plugin

In Visual studio right click "Class1.cs" in the solution explorer and rename it to "Plugin.cs". Choose "Yes" to rename all references

If you do not have a Class1.cs you can create Plugin.cs instead by choosing Project > Add Class...

Copy and paste the following code into "Plugin.cs" replacing the entire contents of the file

If you do not see where to paste the code into, double click the Plugin.cs file in the solution explorer

using BepInEx;
using BepInEx.Unity.IL2CPP;

namespace MyFirstPlugin;

[BepInPlugin("NewbiePluginAuthor.MyFirstPlugin", "MyFirstPlugin", "1.0.0")]
public class Plugin : BasePlugin
{
    public override void Load()
    {
        // Plugin startup logic
        Log.LogInfo("MyFirstPlugin is loaded!");
    }
}

Save your changes by selecting File > Save Plugin.cs

You should now be ready to compile your first plugin

Explaining how this work

We create a new class that inherits from the BepInEx BasePlugin class. We give this new class a special attribute (the BepInPlugin thing above the class) which BepInEx uses to make this class into a full-fledged plugin. The arguments we supply to the attribute include:

  • The GUID: "NewbiePluginAuthor.MyFirstPlugin" This is an identifier which should uniquely identify the plugin. Typically just author.pluginname should suffice.

  • The plugin name: "MyFirstPlugin"

PreviousCreating a C# class library projectNextCompiling for release

Last updated 7 months ago

Was this helpful?

The plugin version: "1.0.0" This uses .

👶
semantic versioning