Valheim Unity Project Guide - Valheim-Modding/Wiki GitHub Wiki
|
Download/install the following:
-
Git
- Choose the version for your machine. Here is a quick-link to the windows download Install Git on Windows
- Once Git is installed, reboot your machine and continue through this guide! Rebooting might not be needed in some cases, but it's advised to do so.
-
AssetRipper
- Extract it somewhere for later. Downloading a version above 1.0.12 seems to corrupt meshes but need more investigation.
-
Unity Hub
- Click on Download Unity Hub and install it.
-
Unity 2022.3.50f1
- Click on the link in Install this version with Unity Hub..
- When installing Unity, you can uncheck all optional modules.
- Run AssetRipper by launching the AssetRipper.GUI.Free.exe. It will open up a console window as well as a page in your browser. Click File -> Settings
- Use these settings.
- Go to File ⟶ Open Folder. Find your Valheim directory and select the top level "Valheim" folder. (You can also drag the folder into AssetRipper).
- If this error shows up you can ignore it.
- Once loaded, go to Export ⟶ Export all Files and select a new empty directory (i.e.
ValheimRIP
).
- Once loaded click Select Folder and then Export and let it complete.
-
You will now have two folders inside your exported folder called AuxiliaryFiles and ExportedProject. Delete AuxileryFiles and rename ExportedProject to something like
ValheimRIP
and move it to it's permanent location. -
Find the manifest.json in Packages located in the folder you exported to and add these values. In case your manifest.json got corrupted you can copy-paste it from HERE
"com.unity.inputsystem": "1.10.0", "com.unity.textmeshpro": "3.2.0-pre.5"
-
Delete these files + their META files in Assets/Plugins. It is very important you do this before opening your project.
Unity.InputSystem.dll, Unity.InputSystem.ForUI.dll Unity.TextMeshPro.dll
-
Restoring shaders.
- Download Yaml shaders.
- Copy the content of the zip into Assets/Shader and overwrite.
-
Run Unity Hub.
-
Click on Open (or Add in new versions).
-
Find the folder where you moved
ValheimRIP
to. -
Select
ValheimRIP
folder and click Open. This will take up to 20-30 mins. -
If the API Update Required message box appears, click I Made a Backup. Go Ahead!. (This only occur when picking Decompiled.)
If the Do you want to enable the backends? appears, click Yes.
-
Wait for the project to fully load (this can take up to 30 mins).
- Go to Edit -> Project Settings -> Graphics and change Custom Shaders to Built-in Shader.
- Open wood_portal to confirm that effects/particles looks good by playing them.
-
Perform a script recovery if needed (This shouldn't happen if you did step 8 in previous section).
- Install NG Script Recovery via Package Manager from the Unity Asset Store
- Open NG Script Recovery from the inspector where the missing script is, or from the menu Window -> NG Tools -> NG Missing Script Recovery
- In the Project tab select "Prefab", "Asset", "GameObject in Scenes"and "Scenes". Hit the Scan button.
- Hit "Start Recovery" to perform an automatic recovery.
- You may see a pop-up asking you to import TMP Essentials. Click "Import TMP Essentials" and close the pop-up.
- Finish the script recovery by manually picking the best match for any remaining broken object until the process is finished.
-
Click Window and then open AssetBundleBrowser, click the first bundle and then ctrl+A to select all, now delete and wait for it to finish. Depending on your system it might take a little bit and then it will do another import session like when you first opened the rip.
- If you don't have AssetBundleBrowser, go to the Unity Technologies GitHub page for it and follow the instructions under Installation.
-
You should now have a good rip you can work on. There will still be a few missing materials, scripts in scenes. These are not urgent to fix but you can if you want. For convenience you can put all missing materials to Standard. For fonts you can use any of the TMP ones. This step is only useful if you care about exploring scenes with working shaders, text and if you don't you can ignore this. It's possible to fully restore scenes and correct any shaders to match vanilla. That's however outside of the scope of this guide and you can join any modding Discord for help with that.
-
[Optional] Create a copy of your
ValheimRIP
folder in the same directory. Rename the copy to something likeValheimRIPCustom
. YourValheimRIP
folder will be used as a clean version of the ripped game assets and theValheimRIPCustom
version is where you will duplicate, create new, or edit existing assets. -
[Optional] Create another copy of your
ValheimRIP
and call itValheimTemplate
and then delete the content of the Asset folder. You can then copy-paste this project for each mod you want to make. You then useValheimCustom
to export assets into your new clean project. This is beneficial as you only export what you need and not accidentally bring in the whole game from automatic references.
If you need further help you can join any of the modding Discords linked here.
🥳 That's it. Happy modding! Keep reading for more information.
-
Dummy shaders are editable and can be used with Shader Replacer but effects/particles looks broken in Unity.
-
Yaml shaders are not editable but effects/particles looks correct in Unity (you will need to recover them first).
-
Pick Dummy if you want to use Valheims shaders with Shader Replacer and you do not care about effects/particles that looks broken (white/pink squares or other artifact looking graphics)
-
Pick Yaml if you want to have effects/particles that look correct and that you can use as reference when replacing them with standard, legacy, custom.
If you are creating assets for the game you will want to make sure your build is compatible with Vulkan and OpenGL graphics. If you do not do this for your project then some items in the game will show up incorrectly, typically untextured bright pink/magenta, for some players and there will be related errors in Player.log.
- Open your unity development project.
- Go to Edit -> Project Settings.
- In the Player tab find the "Other settings".
- Uncheck "Auto Graphics API for Windows".
- Under "Graphics APIs for Windows" make sure both "Direct3D11" and "Vulkan" are added.
- Uncheck "Auto Graphics API for Linux".
- Under "Graphics APIs for Linux" make sure both "OpenGLCore" and "Vulkan" are added.
Error message example, showing missing OpenGL support:
Desired shader compiler platform 15 is not available in shader blob
ERROR: Shader Unlit/Color shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
These common error logs can be ignored for now.
Destroy may not be called from edit mode! Use DestroyImmediate instead.
Destroying an object in edit mode destroys it permanently.
Assertion failed on expression: 'CurrentThreadIsMainThread()'
- Mouse does not get locked to the playtest window.
- Some UI elements like the stamina bar don't disappear or will flash.
Use these versions when ripping the older game version:
-
AssetRipper 0.3.0.0
- This version is a December pre-release, not the latest version.
- Under Assets, download
AssetRipperGUI_Your Operating System.zip
. - Extract it somewhere for later.
-
ValheimExportHelper 1.5.0
- Under Assets, download
ValheimExportHelper.zip
. - Extract all (4) files to the
AssetRipper/Plugins
directory (create aPlugins
folder if it is missing).
- Under Assets, download
-
Unity 2020.3.45
- Click on the link in Install this version with Unity Hub..
- When installing Unity, you can uncheck all optional modules.
The purpose of the Unity Asset Bundle Browser tool is to export your modded prefabs into a standalone asset bundle.
- Go to Window ⟶ Package Manager.
- Click on the ➕▼ button and choose Add package from git URL.
- Paste
https://github.com/Unity-Technologies/AssetBundles-Browser.git
and click Add.
|
-
Run AssetRipper.
-
Set Script Export Format to Dll Export Without Renaming.
-
Go to File ⟶ Open Folder and find your Valheim directory.
-
Once loaded, go to Export ⟶ Export all Files and select a new empty directory (i.e.
valheim_unity
).
-
Wait for it to finish.
-
Run Unity Hub.
-
Click on Open.
-
Find and select
valheim_unity/valheim/ExportedProject
and click Open. -
If the API Update Required message box appears, click I Made a Backup. Go Ahead!.
-
If the Enter Safe Mode? message box appears... (click for more)
-
Click Enter Safe Mode.
-
If you see two error messages involving
Library\PackageCache\com.unity.collab-proxy
...
-
Go to Window ⟶ Package Manager.
-
Click on the Packages dropdown and choose In Project.
-
Select Version Control from the list and click Remove.
-
-
If you have other problems, consult the Discord.
-
-
Wait until the project is fully loaded.
These changes are to fix compatibility issues with exported assets in Valheim.
-
Click Edit ⟶ Project Settings...
- Under Player ⟶ Other Settings ⟶ Rendering...
- Uncheck Auto Graphics API for Windows
- Uncheck Auto Graphics API for Linux
- Click the ➕ under Graphics APIs for Windows and choose Vulkan to add it to the list.
- Under Graphics ⟶ Built-in Shader Settings, change the Deferred option from
Custom shaderto Built-in shader.
- Under Player ⟶ Other Settings ⟶ Rendering...
|
Follow Step 1: Rip Assets from the base tutorial with the following changes:
- Do NOT change Script Export Format or any other options. Leave it as Decompiled (the default).
Make the following changes to the source files in your valheim/ExportedProject/Assets/MonoScript
directory created by the previous step. These can be done easily by opening the directory in a powerful editor (i.e. Visual Studio Code or similar).
- Replace all of the following occurrences in all project files (Replace in Files):
-
StructLayout(0
⟶StructLayout(LayoutKind.Sequential
-
StructLayout(2
⟶StructLayout(LayoutKind.Explicit
-
- In
assembly_steamworks/Steamworks/Callback.cs
, delete the entire block inprivate event DispatchDelegate m_Func { ... }
, replace it withprivate event DispatchDelegate m_Func;
. - In
assembly_steamworks/Steamworks/CallResult.cs
, delete the entire block inprivate event APIDispatchDelegate m_Func { ... }
, replace it withprivate event APIDispatchDelegate m_Func;
. - In
assembly_utils/Utils.cs
, replaceCompressionLevel.Fastest
withSystem.IO.Compression.CompressionLevel.Fastest
. - In
assembly_valheim/Heightmap.cs
delete[ExecuteInEditMode]
.
Continue the base tutorial as normal from Step 2: Open in Unity.