Something to remember is If you make your game using C# anyone can read and copy your code using readily available tools. The same applies to everything made with the Unity engine. Thatâs why many Unity devs also spend extra money and pay a 3rd party in an attempt to âprotectâ their code. Using C++ with the Flax engine makes it harder for someone to read and copy your code.
If you do your game/app/project in C# you can also obfuscate the code yourself. You can use long variable names and make function/method names nonsensical and put code in your game that does do something but actually doesnât affect your game at all, like constantly add two numbers together. But make it so if that function is removed from the code it breaks your game. The objective being if someone wants to hack/steal/pirate your code they will consider it a waste of their time and move onto something easier to steal.
From the following website: Game Data Security | Flax Documentation
" Code
Depending on the scripting language used in the game project it might be more or less secure. There are several actions that can increase the final security of the game but remember that it might be very hard or nearly impossible to secure the game fully.
C#
Game code is compiled into .Net assemblies - separate for each binary module such as Game.CSharp.dll
(default). Thus no source code is deployed with the game. However, C# DLLs can be easily decompiled with the various tools which make it insecure. Possible ways to overcome this:
-
Obfuscation tools (eg. Eazfuscator.NET, ConfuserEx, neo-ConfuserEx, Babel Obfuscator, etc.) - those can mangle code-flow, variable names, constants, and types. But if the class typenames or field/properties get renamed it might lead to incorrect deserialization when loading scenes or prefabs. For this case Serialization Callbacks can be used to load the data from the asset for runtime.
-
Code signing - after project compilation all game DLLs can be signed with a code-signing certificate which allows validating the file upon the execution to prevent hacking game files (at least partially).
- Critical-code could be moved into C++ scripts which are compiled directly into the platform bytecode.
C++
Native C++ game code is compiled directly into the target platform executable format (eg. .dll
, .so
, .dylib
, etc.). In Release
mode there is no debug information and all code optimizations are enabled in the compiler. This results in secure code in a way itâs unable to decompile and very hard to hack."