Skip to content

Valheim Unity Project Guide

CookiexMilk edited this page May 17, 2024 · 141 revisions
ℹ️ Note

This is NOT a guide for modding. It is a guide for getting started on custom asset creation for Valheim.

Prerequisites

Download/install the following:

  1. 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.
  2. AssetRipper
    • Extract it somewhere for later. Downloading a version above 1.0.12 seems to corrupt meshes but need more investigation.
  3. Unity Hub
    • Click on Download Unity Hub and install it.
  4. Unity 2022.3.17f1
    • Click on the link in Install this version with Unity Hub..
    • When installing Unity, you can uncheck all optional modules.

Step 1: Rip Assets

  1. 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

Settings

  1. Use these settings.

Settings

  1. Starting Ashlands Prep-Update the project is now organized differently. If you dislike this and want to all assets to be grouped together then change Direct Export to Group By Asset Type.

Settings

  1. Go to FileOpen Folder. Find your Valheim directory and select the top level "Valheim" folder. (You can also drag the folder into AssetRipper).

Settings

  1. Once loaded, go to ExportExport all Files and select a new empty directory (i.e. valheim_unity).

Settings

  1. Once loaded click Select Folder and then Export and let it complete.

Settings

  1. Find the manifest.json in Packages located in the folder you exported to and add these values.
    "com.unity.inputsystem": "1.7.0",
    "com.unity.textmeshpro": "3.2.0-pre.5"
    

manifest.json

  1. Delete AssetRipper in the root folder as well as the Unity.InputSystem.dll, Unity.InputSystem.ForUI.dll and Unity.TextMeshPro.dll + their META files in Assets/Plugins.

  2. Restoring shaders.

    1. Download Yaml shaders.
    2. Unpack and copy the two folders Shader and Shaders to Assets/ and overwrite (If you picked Group Assets By Type then drag the content of the folder Shaders into Shader as well as BuiltInOverrides into Shader).

Step 2: Open in Unity

  1. Run Unity Hub.

  2. Click on Open.

    2022-07-26 00_44_02-Unity Hub 3 2 0
  3. Delete the folder AssetRipper from valheim/Valheim <version> - <date>.

  4. Rename your export folder valheim/Valheim <version> - <date> to whatever you like, i.e. ValheimRIP.

  5. Move the folder ValheimRIP to a permanent location. You can now delete the valheim folder.

  6. Find and select ValheimRIP (or whatever you named it) and click Open. This will take up to 20-30 mins.

  7. If the API Update Required message box appears, click I Made a Backup. Go Ahead!. (This only occur when picking Decompiled.)

    2022-08-04 02_09_59-API Update Required

    If the Do you want to enable the backends? appears, click Yes.

    2022-08-04 02_09_59-API Update Required
  8. Wait for the project to fully load (this can take up to 30 mins).

    1. Go to Edit -> Project Settings -> Graphics and change Custom Shaders to Built-in Shader.
    2. Open wood_portal to confirm that effects/particles looks good by playing them.
  9. Perform a script recovery if needed.

    1. Install NG Script Recovery via Package Manager from the Unity Asset Store
    2. Open NG Script Recovery from the inspector where the missing script is, or from the menu Window -> NG Tools -> NG Missing Script Recovery
    3. In the Project tab select "Prefab", "Asset", "GameObject in Scenes"and "Scenes". Hit the Scan button.
    4. Hit "Start Recovery" to perform an automatic recovery.
    5. You may see a pop-up asking you to import TMP Essentials. Click "Import TMP Essentials" and close the pop-up.
    6. Finish the script recovery by manually picking the best match for any remaining broken object until the process is finished.
  10. 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.

  11. [Optional] Create a copy of your ValheimRIP folder in the same directory. Rename the copy to something like ValheimRIPCustom. Your ValheimRIP folder will be used as a clean version of the ripped game assets and the ValheimRIPCustom version is where you will duplicate, create new, or edit existing assets.

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.

Notes about Shaders

  • 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).

What do I pick?

  • 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.

Notes about Decompiled vs Compiled.

  • Use Decompile if you want to be able to have all the DLLs in a decompiled form and easy access to .cs files. Using this option will result in compiler errors that will need to be fixed.

  • Use DLL Export Without Renaming if you want all your DLLs in a compiled form and don't need easy access to all scripts. Using this option will not result in compiler errors.

Notes on Setting up Graphics APIs

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.

  1. Open your unity development project.
  2. Go to Edit -> Project Settings.
  3. In the Player tab find the "Other settings".
    1. Uncheck "Auto Graphics API for Windows".
    2. Under "Graphics APIs for Windows" make sure both "Direct3D11" and "Vulkan" are added.
    3. Uncheck "Auto Graphics API for Linux".
    4. 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)

Notes on Current Issues

Common Errors

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()'

Common Issues

  • Mouse does not get locked to the playtest window.
  • Some UI elements like the stamina bar don't disappear or will flash.

Game Versions 0.214.3 - 0.217.25

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 a Plugins folder if it is missing).
  • Unity 2020.3.45
    • Click on the link in Install this version with Unity Hub..
    • When installing Unity, you can uncheck all optional modules.

Old Guides 2022

Installing Asset Bundle Browser

The purpose of the Unity Asset Bundle Browser tool is to export your modded prefabs into a standalone asset bundle.

  1. Go to WindowPackage Manager.
    2022-07-28 00_04_28-
  2. Click on the ➕▼ button and choose Add package from git URL.
    2022-07-28 00_04_56-Package Manager
  3. Paste https://github.com/Unity-Technologies/AssetBundles-Browser.git and click Add.
    2022-07-28 00_05_15-Package Manager

Unity Project for Valheim Asset Development

ℹ️ Note

This is a minimalistic tutorial for achieving asset creation in Valheim. It will not allow scene browsing or play testing.

If you want more, follow the advanced tutorial.

Step 1: Rip Assets

  1. Run AssetRipper.

  2. Set Script Export Format to Dll Export Without Renaming.
    2022-07-26 08_01_33-Asset Ripper GUI

  3. Go to FileOpen Folder and find your Valheim directory.
    2022-07-21 19_15_02-Asset Ripper GUI

  4. Once loaded, go to ExportExport all Files and select a new empty directory (i.e. valheim_unity).
    2022-07-21 19_16_21-Asset Ripper GUI

  5. Wait for it to finish.

Step 2: Open in Unity

  1. Run Unity Hub.

  2. Click on Open.
    2022-07-26 00_44_02-Unity Hub 3 2 0

  3. Find and select valheim_unity/valheim/ExportedProject and click Open.

  4. If the API Update Required message box appears, click I Made a Backup. Go Ahead!.

  5. If the Enter Safe Mode? message box appears... (click for more) 2022-07-26 01_45_50-Enter Safe Mode_
    1. Click Enter Safe Mode.

    2. If you see two error messages involving Library\PackageCache\com.unity.collab-proxy...
      2022-07-26 01_53_20-ExportedProject - SAFE MODE - 2020 3 33f1 _DX11_

      1. Go to WindowPackage Manager.
        2022-07-26 15_43_48-ExportedProject - SAFE MODE - 2020 3 30f1 _DX11_

      2. Click on the Packages dropdown and choose In Project.
        2022-07-26 01_57_39-Package Manager

      3. Select Version Control from the list and click Remove.
        2022-07-26 08_10_04-Package Manager

    3. If you have other problems, consult the Discord.

  6. Wait until the project is fully loaded.

Step 3: Compatibility Fixes

These changes are to fix compatibility issues with exported assets in Valheim.

  1. Click EditProject Settings...
    2022-07-26 01_54_39-

    1. Under PlayerOther SettingsRendering...
      1. Uncheck Auto Graphics API for Windows
      2. Uncheck Auto Graphics API for Linux
      3. Click the under Graphics APIs for Windows and choose Vulkan to add it to the list.
        2022-07-26 21_58_48-AssetBundle - SampleScene - PC, Mac   Linux Standalone - Unity 2020 3 33f1 Perso
        2022-07-26 21_47_01-Project Settings
    2. Under GraphicsBuilt-in Shader Settings, change the Deferred option from Custom shader to Built-in shader.
      2022-07-26 08_17_30-Project Settings

(Advanced) Ripping Assets for Valheim Data Mining and Scene Viewing

⚠️ Warning

This tutorial is for advanced users. It may also quickly become outdated.

Step 1: Rip Assets with Source Code

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).

Step 2: Resolving Source Code Issues

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).

  1. Replace all of the following occurrences in all project files (Replace in Files):
    1. StructLayout(0StructLayout(LayoutKind.Sequential
    2. StructLayout(2StructLayout(LayoutKind.Explicit
  2. In assembly_steamworks/Steamworks/Callback.cs, delete the entire block in private event DispatchDelegate m_Func { ... }, replace it with private event DispatchDelegate m_Func;.
  3. In assembly_steamworks/Steamworks/CallResult.cs, delete the entire block in private event APIDispatchDelegate m_Func { ... }, replace it with private event APIDispatchDelegate m_Func;.
  4. In assembly_utils/Utils.cs, replace CompressionLevel.Fastest with System.IO.Compression.CompressionLevel.Fastest.
  5. In assembly_valheim/Heightmap.cs delete [ExecuteInEditMode].

Step 3: Continue the Base Tutorial

Continue the base tutorial as normal from Step 2: Open in Unity.

Other Tutorials

Youtube

Valheim Modding - Ripping the game (Unity Project)

Clone this wiki locally