Sunday, December 9, 2018

Loading a Unity Game into dnSpy

Intro

This will be a quick walk through that explains the basics of loading a Unity based game into dnSpy for editing. This is intended as a common step for editing most Unity based games.

If you have any questions about the process then make sure to leave a comment below and we'll update the guide / clarify any points that are unclear.

1) Download dnSpy.zip

The first step is to download dnSpy. Visit the releases section of the dnSpy GitHub page and download the latest dnSpy.zip.

2) Extract dnSpy.zip

It's important to actually extract dnSpy.zip, do not open it and try to use it without extracting. Right click on the zip and select "Extract All..." from the menu. Press "Extract" on the window that pops up. A new window will popup which shows the extract files.

3) Open dnSpy.exe

With the files extracted, open dnSpy.exe. If you can't see the ".exe" on the end then you may need to change your view options. You may need to open "dnSpy-x86.exe" on a 32 bit computer (if dnSpy.exe isn't working, try dnSpy-x86.exe).

Windows 10:

Open the "View" tab at the top of the explorer window and then turn on "File name extensions" using the checkbox item.


Windows 7:

Press and release the "Alt" key on your keyboard. Select "Tools" and then navigate to "Folder Options". Open the "View" tab and then remove the check from the "Hide extensions for known file types" box.


4) Open Assembly-CSharp.dll

All Unity games generate a similar file structure. Start by opening the directory where the game was installed to. In the case of steam, you can simply right click on a game and then select "Properties", open the "LOCAL FILES" tab, and then press "BROWSE LOCAL FILES...".


All unity games have a folder with the name of the game that ends in "_Data", for example, for 60 seconds, it is called "60Seconds_Data". Open the "_Data" folder. Navigate into the "Managed" folder. The "Assembly-CSharp.dll" file is stored within the "Managed" folder.

The "Assembly-CSharp.dll" file contains the majority of the games code that we will be interested in modifying. Let's open it.

Drag and drop the "Assembly-CSharp.dll" directly into the "Assembly Explorer" within dnSpy.


If you can't see the assembly explorer then you can activate it by opening the "View" menu and then selecting "Assembly Explorer" (Ctrl + Alt + L).


If you are unable to drag and drop into the Assembly Explorer then you can alternately select "File" and then click on "Open" and directly browse to the "Assembly-CSharp.dll" file.

5) Expand the trees

Now that the main file is loaded, lets start exploring the code. The code is sorted into the namespaces and classes within dnSpy. You need to expand the trees in order to find the relevant piece of code to edit.


6) Follow one of our other tutorials

This was the basic setup that is used in many other tutorials. This tutorial was simply to get dnSpy up and running to load up a unity based Assembly-CSharp.dll.

2 comments:

  1. this is definitely a stupid question, but do I need unity to see the games code? When I follow this guide for the game I want to mod, I cant find anything related to the game.

    ReplyDelete
    Replies
    1. Which game is it? You don't need Unity to use dnSpy -- it is possible there is another DLL you need to load though. Share more details and maybe we can help. P.S. I should a better blog

      Delete

Note: Only a member of this blog may post a comment.