-3

I want the actual code used in a library called:

using UnityEngine.Advertisements;

to see

But when I press Ctrl+Enter on it

Only the methods are defined and not their codes like:

        public static void Initialize(string gameId, bool testMode);

Can you see the original codes used?

Matin
  • 3
  • 2
  • https://www.bing.com/search?q=c%23+decompiler+visual+studio finds some tools... not really sure what you use for editing code, so hard to suggest anything specific. – Alexei Levenkov Feb 23 '23 at 18:19
  • Not if the code has been compiled. You could try using a decompiler to reverse-engineer it (possibly a violation of their EULA) but that still won't give you the exact original source code. – Dave S Feb 23 '23 at 18:19
  • @DaveS there is really no correlation between "code has been compiled" and being able to see matching original code while debugging/browsing code.... granted the original code need to be available and properly associated with the assemblies like it is done for .Net code itself. – Alexei Levenkov Feb 23 '23 at 18:21
  • Unity is not open-source I was answering in the context of not having the original source code, where the poster was apparently hoping that browsing or debugging would work for closed libraries the same as for their own code. But yes, for your own EXE and own source being compiled doesn't mean you can't see the source (which is not extracted from the EXE) – Dave S Feb 23 '23 at 18:45
  • 1
    Some of Unitys source code is available on their github. [Unity Cs Reference - GitHub](https://github.com/Unity-Technologies/UnityCsReference) – hijinxbassist Feb 23 '23 at 18:54

1 Answers1

0

Unity is a C++ engine that has a C# layer.

A lot of the C# library code is actually just a way that allows game makers to access that C++ code. So for short, you won't be able to view most of the actual code. I say "actual", because there is also some logic done in C# that handles the "result" (for lack of a better word) part of the engine.

Also, code regarding Unity Services will mostly be on the server anyway. Things like lobby management and monetization is server side, with the C# (and possible the C++) client just handling interaction between the game and the Unity servers.

This is also valid for .NET, Mono, Java and more. Even if you get decompilers and unpack most of the libraries, you won't, for example, see code that returns the current OS username that runs it, since it's on the native layer. This is similar to the same approach UnrealEngine 1, 2 and 3 games had where, while you had access to the UnrealScript code, part of it called native functions in C++.

TheNomad
  • 892
  • 5
  • 6