Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

testing for successful DLLImport

Discussion in 'Scripting' started by mzartler, Feb 10, 2012.

  1. mzartler

    mzartler

    Joined:
    May 15, 2010
    Posts:
    19
    Hi All,
    i'm upgrading our lipsync package for unity. In addition to bulking up the whole product, it supports data from the Lipsync Tool, providing a less expensive, and more portable, option when dealing with pre-recorded audio. The scripts are mostly shared between lipsync data sourced from the microphone (via plugin) or sourced from a text asset (from the lipsync tool).

    Everything is kosher except that I have an instance where i'd like to know whether i've got the plugin. when the plugin is available, and a case where it's not. Trying to avoid DllNotFoundException from unity.

    LipsyncPlugin is my C# wrapper around native code:
    LipsyncPlugin._CloseMicrophone()

    I tried to test for null
    if (LipsyncPlugin._CloseMicrophone() != null)

    Nope. Compile error.

    Any tricks or tips?

    Thanks and Cheers!

    Mark
     
  2. Nems

    Nems

    Joined:
    Jul 18, 2011
    Posts:
    65
    You can try to call the CloseMicrophone function and catch the the DllNotFoundException.
    If the exception occurs, then the Dll is not present ; else it is.

    Nems