Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

How to get all System.Relection.Assembly for all module in unity.

Discussion in 'Scripting' started by watsonsong, Jan 9, 2020.

  1. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    I can get all assemblies by using CompilationPipeline.GetAssemblies(). But I can not find a way to covert the UnityEditor.Compilation.Assembly into System.Relection.Assembly.

    Is there a way to gets all System.Relection.Assembly in a project?
     
  2. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,169
    You can use ‘System.AppDomain.currentDomain.GetAssemblies()’ to get all loaded assemblies in the project. This works in editor and at runtime.
     
    BackgroundMover likes this.
  3. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    So I should compare them with the CompilationPipeline.GetAssemblies() and matching them by the AssemblyName?
    That seems work, I am thought it is fragile.
     
  4. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,169
    So it sounds like you just want to get the loaded assemblies that Unity is compiling? In that case comparing by name is probably your only option but I would suggest comparing against the 'AssemblyName.FullName' property because it contains versioning information. It should be robust enough because even assembly reference metadata only contains assembly name and version info.
     
    Bunny83 likes this.
  5. Vongola_Bili

    Vongola_Bili

    Joined:
    Aug 15, 2021
    Posts:
    4
    Maybe 'AssemblyDefinitionReferenceGUIDToGUID' will help you.
    I try to do with it but don't work.
    If you get it well , please tell me.
     
    tokar_dev likes this.