How to check assemblies types in Unity C#
If you’re distributing unity packages. You might have heard about the common practise to use reflection code to determine whether a type is present or not?
Reflection code helps in not being dependent on a third-party library. You can distribute your Unity package without adding third-party libraries to it.
The first step is identifying how we can detect third-party libraries are present in a Unity project.
To do that, you need to find how to detect assemblies in a Unity project.
.Net framework has the following method which helps to get the assemblies in the project.
public static void Main()
//Make an array for the list of assemblies.
Assembly assems = currentDomain.GetAssemblies();
//List the assemblies in the current application domain.
Console.WriteLine("List of assemblies loaded in current appdomain:");
foreach (Assembly assem in assems)
For more information — https://docs.microsoft.com/en-us/dotnet/api/system.appdomain.getassemblies
foreach (Assembly assem in assems) gives the output of every assembly.
Next, you need to find the types of assembly.
.Net framework has the following method which helps to get types in assembly.
For more information — https://docs.microsoft.com/en-us/dotnet/api/system.reflection.assembly.gettypes
If you like my articles, please follow me. You can also support me by https://www.buymeacoffee.com/akarshseggemu