A Valheim mod stub project using Jötunn including build tools and a basic Unity project stub. There is no actual plugin content included, just a minimum plugin class.
Please see Jötunn Docs detailed documentation and setup.
Included in this repo is a PowerShell script publish.ps1
.
The script is referenced in the project file as a post-build event.
Depending on the chosen configuration in Visual Studio the script executes the following actions.
The compiled dll and a dll.mdb debug file are copied to <ValheimDir>\BepInEx\plugins
(or the path set in MOD_DEPLOYPATH).
A compressed file with the binaries is created in <JotunnModStub>\Packages
ready for upload to ThunderStore.
Dont forget to include your information in the manifest.json and to change the project's readme file.
New Assets can be created with Unity and imported into Valheim using the mod.
A Unity project is included in this repository under <JotunnModStub>\JotunnModUnity
.
- Download UnityHub directly from Unity or install it with the Visual Studio Installer via
Individual Components
->Visual Studio Tools for Unity
- You will need an Unity account to register your PC and get a free licence. Create the account, login with it in Unity Hub and get your licence via
Settings
->Licence Management
- Install Unity Editor version 2022.3.17f
- Compile the project. This copies all assemblies into
<JotunnModStub>\JotunnModUnity\Assets\Assemblies
. Don't open Unity yet before this step, it will remove assembly references. - Warning: These assembly files are copyrighted material and you can theoretically get into trouble when you distribute them in your github repository. To avoid that there is a .gitignore file in the Unity project folder. Keep that when you clone or copy this repository
- Open Unity Hub and add the JotunnModUnity project
- Open the project in Unity
- Install the
AssetBundle Browser
package in the Unity Editor viaWindow
->Package Manager
for easy bundle creation
See the Wiki page Debugging Plugins via IDE for more information
When Valheim updates it is likely that parts of the assembly files change. If this is the case, the references to the assembly files must be renewed in Visual Studio and Unity.
- There is a file called DoPrebuild.props included in the solution. When you set its only value to true, Jötunn will automatically generate publicized assemblies for you. Otherwise you have to do this step manually.
- Copy all
assembly_*.dll
from<ValheimDir>\valheim_Data\Managed
into<JotunnModStub>\JotunnModUnity\Assets\Assemblies
.
Do this directly in the filesystem - don't import the dlls in Unity. - Go to Unity Editor and press
Ctrl+R
. This reloads all files from the filesystem and "re-imports" the copied dlls into the project.