Search Unity

How can I use a C Library while running in Editor?

Discussion in 'Scripting' started by eppz, Jan 17, 2018.

  1. eppz

    eppz

    Joined:
    Aug 2, 2014
    Posts:
    172
    I have a C Library I want to use.
    It has a bunch of .h and .c files, also the library is compiled to an .a archive.

    I'm aware that I could use it as a plugin (using DllImport), but AFAIK it would be accessible only in the runtime of a native player build.

    Is there any way to use the library in Editor test sessions?
     
  2. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    Well, the editor code needs to be compiled and executed at some point as well. So you should just try it (you need it as a .dll that's compiled for your OS though).
     
    eppz likes this.
  3. eppz

    eppz

    Joined:
    Aug 2, 2014
    Posts:
    172
  4. eppz

    eppz

    Joined:
    Aug 2, 2014
    Posts:
    172
    Wow, it just works using simple MacOS Dynamic Library target.
    Note that Unity only imports it using bundle extension.
     
    Last edited: Jan 17, 2018
    Suddoha likes this.
  5. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    Oh that sounds pretty easy. I've never worked with MacOS or iOS, but it's still nice to know.