Tutorial  Updated

How to create Nintendo Switch games with Unity.

Note: NSPs build with a leaked SDK are not allowed to be shared on GBATemp (and most likely nowhere else too) because they were build with "stolen code". These NSPs can only be installed on hacked switches with sigpatches, so please only do projects for yourself instead of publishing them and making Nintendo mad & possibly even sue you.




Foreword:
If you are some random kid that wants to make a game for the switch without knowledge about Unity, Switch development and C/C++, stop right here. This is not meant for you and if you want to make a game that runs on the switch, use Godot. It is easy to make games with and they are legal to share. Dont expect any kind of help for making "illegal games", especially not if you cant read error messages to figure things out on your own.



Prerequisites
  • A leaked (or official) Nintendo Switch SDK from Nintendo (for example NX SDK 15.3.0) *
  • The corresponding Unity version (for example 2023.1.0b2)
  • The corresponding Unity "support for editor" addon. **
  • https://github.com/The-4n/hacPack on your harddrive and added to your PATH environment variable

* I will not provide links to any SDK, nor will i tell you where to find it. Don't even ask.
** These links, while not publicly shared, are not protected in any way by unity. If you have the link from their website, you can download them without any restriction. However i still wont provide any URLs.

The leaked SDKs that you can find online usually do not have the same folder structure. They are often incomplete, scrambled or in other ways messed up which makes it hard to write a unified guide for them. I will therefore base this guide on a 15.3.0 SDK that recently leaked. Your experience might be different and its a lot of trial and error to get it working.


Folder structure of the recently leaked SDK:
1675693698611.png




"Installing" the SDK

The complete SDK consists of many "addons" and most (if not all) of them are needed to make the build process work. You basically want to go through all folders and check if they have either a "NintendoSDK", "NintendoSDK-NEX", "NintendoSDK-NPLN" or "NintendoSDK-Pia6" subfolder and then merge them on your harddrive. Usually you will not overwrite any files except for maybe a license file. If you do this, you basically have a complete SDK with all addons installed to it. This is how it should look like on your harddrive once you are done (- the combined size is about 24GB.):
1675694161728.png



After you have extracted the necessary data, its time to add some environment variables. The folder path changes depending on where you put the SDK files obviously.
Restart your PC for them to take effect.
1675694314291.png





Installing Unity + Addon

Now you can install Unity and its "support for editor" addon. Make sure to install the correct version of both Unity and the addon, since the SDK is made for these specifically. You might get away with some versions lower and higher but there is absolutly no guarantee. Its best if you don't mix and match but choose the correct one. Usually the addon is delivered with the leaked SDK itself, which also tells you what Unity version to use.





Creating a game (or whatever)

It is highly advised that you read the documentation that comes with the SDK!

Stuff like character controller / HID and what not are all explained in the documentation. READ IT.

Once you are happy with your game (or whatever), click "File -> Build Settings" and change the Platform to Nintendo Switch. Let everything load, check the "Create NSP ROM File" checkbox and adjust all the NMETA settings in the "Player Settings" menu. I wont go over that stuff as its a lot and i am sure you can read and figure it out on your own. Click "Build" to create an NSP.

1675695144004.png






Making it installable

If you did everything correctly, you should now have an NSP file. But lets be honest, you do not own a dev unit to install the NSP on, do you?
Well, to be able to install and play your game on a retail switch, you need to repack it with your own retail unit keys. Use lockpick_rcm to get them and place them in (create if the folder does not exist):
Code:
C:\Users\<YOUR USER NAME>\.switch

You can then use hactool or any other method of your liking to repack the NSP. I created a simple repacker (check attachments) that does the job for me, however i wont guarantee that it works for you too. Either double-click the files or simply drag an NSP onto them. Its python code converted to an EXE so it might trigger your AV. You don't have to use it if you don't trust it but repacking research has to be done by you then.

Make sure that hacpack is on your harddrive and added to your PATH envoronment variable.
1675696284973.png


To use my repacker, the NSP needs to have its titleID somewhere inside the filename. You can check the titleID in Unity under "Player Settings -> Publishing Settings" as "Application ID" (the 0x is NOT part of the titleID). So you can rename your NSP to something like "mygame_01004b9000490000.nsp or whatever you like, then simply drag the NSP on repacker.exe.

Once you have a repacked NSP, you can install it to a retail unit running Atmosphere with sigpatches.
Have fun creating some games!





Result

The result could look like this:


2023020616251200-57B4628D2267231D57E0FC1078C0596D.jpg
PXL_20230111_050837650.jpg
 

Attachments

  • repack.7z
    5.9 MB · Views: 97
Last edited by Slluxx,

eetthh8668456

New Member
Newbie
Joined
Feb 12, 2023
Messages
1
Trophies
0
Age
34
XP
18
Country
United States
Thank you for your tutorial, can you provide the original code of repack.exe? I want to learn about the command line usage of python and hactool. Thank you so much!
 

ThatFinn

Well-Known Member
Newcomer
Joined
May 28, 2020
Messages
89
Trophies
0
XP
330
Country
Austria
Wouldn't it be possible to decompile a nsp game made with unity? I decompiled multiple unity games (nsp) and android unity games (il2cpp of course). And I can say in the exefs of every unity switch game the only thing that changes from game to game is the "main" file (aka the switch executable), which also happens to store some code for the game. The rest is in the "global-metadata.dat" file. The Romfs contains a "Data" folder. It look very similiar (maybe even exactly) like Data folder in an android unity game which even has a "global-metadata.dat" and the rest of the code in an android unity game is in the "libil2cpp.so". Since the switch is arm64, wouldn't be possible to transplant the data folder from an android unity game to a unity romfs game and find some way to transplant the code to the "main" file?
PS: you can extract the code with il2cppdumper from the "main" and "global-metadata.dat" file
 

masagrator

The patches guy
Developer
Joined
Oct 14, 2018
Messages
6,270
Trophies
3
XP
12,037
Country
Poland
Wouldn't it be possible to decompile a nsp game made with unity? I decompiled multiple unity games (nsp) and android unity games (il2cpp of course). And I can say in the exefs of every unity switch game the only thing that changes from game to game is the "main" file (aka the switch executable), which also happens to store some code for the game. The rest is in the "global-metadata.dat" file. The Romfs contains a "Data" folder. It look very similiar (maybe even exactly) like Data folder in an android unity game which even has a "global-metadata.dat" and the rest of the code in an android unity game is in the "libil2cpp.so". Since the switch is arm64, wouldn't be possible to transplant the data folder from an android unity game to a unity romfs game and find some way to transplant the code to the "main" file?
PS: you can extract the code with il2cppdumper from the "main" and "global-metadata.dat" file
Jesus, no. You completely don't understand how this works.

I decompiled
No, you didn't. I recommend to read what this word means.

And I can say in the exefs of every unity switch game the only thing that changes from game to game is the "main" file (aka the switch executable), which also happens to store some code for the game.
It stores whole game's code on Switch if there is no NRO file in romfs.

The rest is in the "global-metadata.dat" file.
This file stores only strings and function signatures. It doesn't store any game's executable code.
Only two files can store CPU executable code on Switch - NSO and NRO. Nothing more.

Since the switch is arm64, wouldn't be possible to transplant the data folder from an android unity game to a unity romfs game
You would need to write very comprehensive wrapper to replace any android specific data with something equivalent to HOS release + fix every possible serializing issue with romfs.

and find some way to transplant the code to the "main" file?
If you would know how executable is build, you wouldn't ask such question. Because you would know it would be a huge challenge worth years of work without any knowledge if this will work or not. That's why everybody with some experience does not do it without being handsomely paid.

PS: you can extract the code with il2cppdumper from the "main" and "global-metadata.dat" file
You can't. You can only extract function signatures and strings to apply to disassembler.

I feel so much hype from your post and equivalent level of complete lack of knowledge.
 

gdavies

Well-Known Member
Newcomer
Joined
Mar 1, 2023
Messages
67
Trophies
0
XP
115
Country
United Kingdom
think someone at nintendo is going to having words when they find out who leaked it, but yay to them all the same
 

ackerned

Member
Newcomer
Joined
Aug 22, 2022
Messages
8
Trophies
0
Age
37
Location
Philippines
XP
65
Country
Philippines


I got every part from start to building nsp file
until i encountered this one

"
Making it installable

If you did everything correctly, you should now have an NSP file. But lets be honest, you do not own a dev unit to install the NSP on, do you?
Well, to be able to install and play your game on a retail switch, you need to repack it with your own retail unit keys. Use lockpick_rcm to get them and place them in
Code:
C:\Users\<YOUR USER NAME>\.switch"

like you said here i use lockpick_rcm and it gives me dev.keys
now i wanna know where exectly to put this dev.keys
and any recommended repacking tools?

because after that part i don't know what to do
 

thesjaakspoiler

Well-Known Member
Member
Joined
Nov 20, 2018
Messages
973
Trophies
0
Age
124
XP
1,481
Country
Afghanistan
like you said here i use lockpick_rcm and it gives me dev.keys
now i wanna know where exectly to put this dev.keys
If your username is 'thatcooldude' then you should have a folder called
C:\Users\thatcooldude\.switch
This is just a hidden folder called 'switch' in the top folder of your account on a windows machine.
Hactool and other tools look in that folder for your dev keys.
and any recommended repacking tools?

There is a tool by the author attached to the first post.
He also mentions 'hactools'.
 
  • Like
Reactions: Slluxx

ackerned

Member
Newcomer
Joined
Aug 22, 2022
Messages
8
Trophies
0
Age
37
Location
Philippines
XP
65
Country
Philippines
If your username is 'thatcooldude' then you should have a folder called

This is just a hidden folder called 'switch' in the top folder of your account on a windows machine.
Hactool and other tools look in that folder for your dev keys.


There is a tool by the author attached to the first post.
He also mentions 'hactools'.
hi thanks for the help i get my switch into lockpick_rcm again i dump one from sysnand and one from emunand so i have title.key dev.key product.key so which of them i need to put in my drive c
regarding about .switch

i put it in my C://user/andrew/

didn;t saw .switch folder or something
 

Slluxx

GBATemp Mayor
OP
Developer
Joined
Jul 17, 2019
Messages
607
Trophies
0
XP
2,147
Country
Germany
hi thanks for the help i get my switch into lockpick_rcm again i dump one from sysnand and one from emunand so i have title.key dev.key product.key so which of them i need to put in my drive c
regarding about .switch

i put it in my C://user/andrew/

didn;t saw .switch folder or something
If there is a path that you dont have, create it.
Code:
C:\Users\andrew\.switch\
just dump all the files you got from lockpick there and you will be fine. its not that hard
 
  • Like
Reactions: Notnagel

Slluxx

GBATemp Mayor
OP
Developer
Joined
Jul 17, 2019
Messages
607
Trophies
0
XP
2,147
Country
Germany
thanks then after that i need to extract the nsp file? or i will proceed to your repack.exe?
Its up to you how you proceed with repacking the NSP file. Instead of asking me like that, you should tell me whats unclear about the guide so i can change it if nessesary.
 

rama_jecboom

New Member
Newbie
Joined
Apr 17, 2023
Messages
3
Trophies
0
Age
25
XP
31
Country
United States
Hi, as the game is made on a hacked switch, is there any way to get it to read files from the system, because no matter how I try, the most I can get is rom:// of the game itself
 

Slluxx

GBATemp Mayor
OP
Developer
Joined
Jul 17, 2019
Messages
607
Trophies
0
XP
2,147
Country
Germany
Hi, as the game is made on a hacked switch, is there any way to get it to read files from the system, because no matter how I try, the most I can get is rom:// of the game itself

the game is not made on a hacked switch. The game is made on a computer with the nintendo sdk. and the nintendo sdk does not know that you are installing it on a hacked retail unit. It creates nsps for real dev units. Games are not supposed to have sdcard access.

I think i saw in the documentation that devkit units have FS access but i don't think that translates to retail units. If you need to save stuff, do it within a savegame like you are supposed to.

EDIT:
Read the docs.
 

Attachments

  • Unbenannt.jpg
    Unbenannt.jpg
    194.8 KB · Views: 79
  • Unbenannt.jpg
    Unbenannt.jpg
    130.8 KB · Views: 80
Last edited by Slluxx,

rama_jecboom

New Member
Newbie
Joined
Apr 17, 2023
Messages
3
Trophies
0
Age
25
XP
31
Country
United States
the game is not made on a hacked switch. The game is made on a computer with the nintendo sdk. and the nintendo sdk does not know that you are installing it on a hacked retail unit. It creates nsps for real dev units. Games are not supposed to have sdcard access.

I think i saw in the documentation that devkit units have FS access but i don't think that translates to retail units. If you need to save stuff, do it within a savegame like you are supposed to.

EDIT:
Read the docs.
Okey, but what about apps like tinfoil and etc, this apps have access to fs
 

ScyllaDwane

New Member
Newbie
Joined
Apr 21, 2023
Messages
1
Trophies
0
Age
26
XP
17
Country
United Kingdom
unless you look at the cached page from where that leak got posted from that site which got taken down by clicking the three bullet list on the google search page, but i won't tell or show the link here cause of piracy reasons.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    K3Nv2 @ K3Nv2: No sharing