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. Dismiss Notice

How to programmatically change Assembly import settings

Discussion in 'Editor & General Support' started by Stranger-Games, Sep 27, 2017.

  1. Stranger-Games

    Stranger-Games

    Joined:
    May 10, 2014
    Posts:
    392
    Hi,

    I have a DLL that dynamically imported into project. After the DLL is imported I want to change programmatically the platforms for it. I want it to only work with editor for example.

    upload_2017-9-27_17-9-17.png

    I tried the following code

    Code (CSharp):
    1. UnityEngine.Object assembly = AssetDatabase.LoadMainAssetAtPath (relativePath);
    2. UnityEngine.Debug.Log (assembly.GetType());
    is printed, and I am not sure how to use DefaultAsset to do what I stated above.

    Thanks for advance.
     
  2. Stranger-Games

    Stranger-Games

    Joined:
    May 10, 2014
    Posts:
    392
    OK, I found the solution.

    Code (CSharp):
    1. PluginImporter importer = AssetImporter.GetAtPath (relativePath) as PluginImporter;
    2. importer.SetCompatibleWithAnyPlatform (false);
    3. importer.SetCompatibleWithEditor (true);
     
  3. DogF

    DogF

    Joined:
    Dec 31, 2013
    Posts:
    29
    no this do not work
     
  4. DogF

    DogF

    Joined:
    Dec 31, 2013
    Posts:
    29
    This do not work.Code can execute,but nothing changed.