Skip to content

Commit 93845d1

Browse files
committed
Added smarter lib finding for Unity users, taking advantage of Unity compiler directives.
1 parent 5cf4d63 commit 93845d1

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

LSL.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,9 +841,32 @@ public static void check_error(int ec) {
841841

842842
class dll
843843
{
844-
/// Name of the binary to include -- replace this if you are on a non-Windows platform (e.g., liblsl64.so)
845-
const string libname = "liblsl32.dll";
846844

845+
#if (UNITY_EDITOR_LINUX && UNITY_EDITOR_64) || UNITY_STANDALONE_LINUX
846+
const string libname = "liblsl64.so";
847+
#elif UNITY_EDITOR_LINUX
848+
const string libname = "liblsl32.so";
849+
#elif UNITY_STANDALONE_LINUX
850+
const string libname = "liblsl.so";
851+
#elif Unity_EDITOR_OSX || UNITY_STANDALONE_OSX
852+
//32-bit dylib no longer provided.
853+
const string libname = "liblsl64";
854+
#elif UNITY_STANDALONE_OSX
855+
const string libname = "liblsl";
856+
#elif (UNITY_EDITOR_WIN && UNITY_EDITOR_64)
857+
libname = "liblsl64";
858+
#elif UNITY_EDITOR_WIN
859+
libname = "liblsl32";
860+
#elif UNITY_STANDALONE_WIN
861+
// a build hook will took care that the correct dll will be renamed after a successfull build
862+
libname = "liblsl";
863+
#elif UNITY_ANDROID
864+
const string libname = "lslAndroid";
865+
#else
866+
// Name of the binary to include -- replace this if on non-Windows and non-Unity (e.g., liblsl64.so)
867+
const string libname = "liblsl32.dll";
868+
#endif
869+
847870
[DllImport(libname, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
848871
public static extern int lsl_protocol_version();
849872

0 commit comments

Comments
 (0)