-
-
Save martindevans/397afa11580fbf0da46072f900cab17f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics.CodeAnalysis; | |
using System.Runtime.InteropServices; | |
using UnityEngine; | |
namespace Assets | |
{ | |
public class TestOpus | |
: MonoBehaviour | |
{ | |
public bool TestNow; | |
void Update() | |
{ | |
if (TestNow) | |
{ | |
TestNow = false; | |
Debug.Log(OpusVersion()); | |
} | |
} | |
public static string OpusVersion() | |
{ | |
// ReSharper disable once AssignNullToNotNullAttribute | |
return Marshal.PtrToStringAnsi(OpusNativeMethods.opus_get_version_string()); | |
} | |
#if UNITY_IOS && !UNITY_EDITOR | |
private const string ImportString = "__Internal"; | |
private const CallingConvention Convention = CallingConvention.Cdecl; | |
#else | |
private const string ImportString = "opus"; | |
private const CallingConvention Convention = CallingConvention.Cdecl; | |
#endif | |
/// <summary> | |
/// General opus methods | |
/// </summary> | |
private static partial class OpusNativeMethods | |
{ | |
#if UNITY_IOS && !UNITY_EDITOR | |
[DllImport("__Internal", CallingConvention = CallingConvention.Cdecl)] | |
#else | |
[DllImport(ImportString, EntryPoint = "opus_get_version_string", CallingConvention = CallingConvention.Cdecl)] | |
#endif | |
internal static extern IntPtr opus_get_version_string(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment