To call native functions, use [DllImport]:
[DllImport("MyNativeLibrary")]
public static extern int Foo(int arg);
Burst also supports internal calls implemented inside Unity:
// In UnityEngine.Mathf
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern int ClosestPowerOfTwo(int value);
DllImport is only supported for native plug-insA platform-specific native code library that is created outside of Unity for use in Unity. Allows you can access features like OS calls and third-party code libraries that would otherwise not be available to Unity. More info
See in Glossary, not platform-dependent libraries like kernel32.dll.
For all DllImport and internal calls, you can only use the following types as parameter or return types:
| Type | Supported type |
|---|---|
| Built-in and intrinsic types |
|
| Pointers and references |
|
| Handle structs |
|
Note: Passing structs by value isn’t supported; you need to pass them through a pointer or reference. The only exception is that handle structs are supported. These are structs that contain a single field of pointer or integer type.