diff --git a/Legacy/ProjectSettings/ProjectVersion.txt b/Legacy/ProjectSettings/ProjectVersion.txt index 91206fd..da67189 100644 --- a/Legacy/ProjectSettings/ProjectVersion.txt +++ b/Legacy/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2022.3.13f1 -m_EditorVersionWithRevision: 2022.3.13f1 (5f90a5ebde0f) +m_EditorVersion: 2022.3.14f1 +m_EditorVersionWithRevision: 2022.3.14f1 (eff2de9070d8) diff --git a/jp.keijiro.klak.syphon/Runtime/Interop/PluginClient.cs b/jp.keijiro.klak.syphon/Runtime/Interop/PluginClient.cs index 5aaea29..28ae10b 100644 --- a/jp.keijiro.klak.syphon/Runtime/Interop/PluginClient.cs +++ b/jp.keijiro.klak.syphon/Runtime/Interop/PluginClient.cs @@ -63,6 +63,8 @@ public Texture2D CreateTexture() #region Unmanaged interface + #if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX + [DllImport("KlakSyphon", EntryPoint = "Plugin_CreateClient")] static extern PluginClient _Create(string name, string appName); @@ -84,6 +86,18 @@ public Texture2D CreateTexture() [DllImport("KlakSyphon", EntryPoint = "Plugin_UpdateClient")] static extern void _Update(PluginClient instance); + #else + + static PluginClient _Create(string name, string appName) => null; + static void _Destroy(IntPtr instance) {} + static bool _IsValid(PluginClient instance) => false; + static IntPtr _GetTexture(PluginClient instance) => IntPtr.Zero; + static int _GetTextureWidth(PluginClient instance) => 0; + static int _GetTextureHeight(PluginClient instance) => 0; + static void _Update(PluginClient instance) {} + + #endif + #endregion } diff --git a/jp.keijiro.klak.syphon/Runtime/Interop/PluginCommon.cs b/jp.keijiro.klak.syphon/Runtime/Interop/PluginCommon.cs index ed66314..e737fdd 100644 --- a/jp.keijiro.klak.syphon/Runtime/Interop/PluginCommon.cs +++ b/jp.keijiro.klak.syphon/Runtime/Interop/PluginCommon.cs @@ -4,11 +4,20 @@ namespace Klak.Syphon.Interop { public static class PluginCommon { + #if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX + [DllImport("KlakSyphon", EntryPoint = "Plugin_EnableColorSpaceConversion")] public static extern void EnableColorSpaceConversion(); [DllImport("KlakSyphon", EntryPoint = "Plugin_DisableColorSpaceConversion")] public static extern void DisableColorSpaceConversion(); + + #else + + public static void EnableColorSpaceConversion() {} + public static void DisableColorSpaceConversion() {} + + #endif } } // namespace Klak.Sypho.Interopn diff --git a/jp.keijiro.klak.syphon/Runtime/Interop/PluginServer.cs b/jp.keijiro.klak.syphon/Runtime/Interop/PluginServer.cs index 3e94f95..a8294b7 100644 --- a/jp.keijiro.klak.syphon/Runtime/Interop/PluginServer.cs +++ b/jp.keijiro.klak.syphon/Runtime/Interop/PluginServer.cs @@ -39,6 +39,7 @@ public static (PluginServer, Texture2D) CreateWithBackedTexture(string name, int width, int height) { var instance = Create(name, width, height); + if (instance == null) return (null, null); var texture = Texture2D.CreateExternalTexture (width, height, TextureFormat.RGBA32, false, false, instance.TexturePointer); @@ -49,6 +50,8 @@ public static (PluginServer, Texture2D) #region Unmanaged interface + #if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX + [DllImport("KlakSyphon", EntryPoint = "Plugin_CreateServer")] static extern PluginServer _Create(string name, int width, int height); @@ -61,6 +64,15 @@ public static (PluginServer, Texture2D) [DllImport("KlakSyphon", EntryPoint = "Plugin_PublishServerTexture")] static extern void _PublishTexture(PluginServer instance); + #else + + static PluginServer _Create(string name, int width, int height) => null; + static void _Destroy(IntPtr instance) {} + static IntPtr _GetTexture(PluginServer instance) => IntPtr.Zero; + static void _PublishTexture(PluginServer instance) {} + + #endif + #endregion } diff --git a/jp.keijiro.klak.syphon/Runtime/Interop/ServerList.cs b/jp.keijiro.klak.syphon/Runtime/Interop/ServerList.cs index 157aa41..762d84f 100644 --- a/jp.keijiro.klak.syphon/Runtime/Interop/ServerList.cs +++ b/jp.keijiro.klak.syphon/Runtime/Interop/ServerList.cs @@ -37,6 +37,8 @@ protected override bool ReleaseHandle() string ToString(IntPtr ptr) => ptr != IntPtr.Zero ? Marshal.PtrToStringAnsi(ptr) : null; + #if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX + [DllImport("KlakSyphon", EntryPoint = "Plugin_CreateServerList")] static extern ServerList _Create(); @@ -52,6 +54,16 @@ string ToString(IntPtr ptr) [DllImport("KlakSyphon", EntryPoint = "Plugin_GetAppNameFromServerList")] static extern IntPtr _GetAppName(ServerList list, int index); + #else + + static ServerList _Create() => null; + static void _Destroy(IntPtr list) {} + static int _GetCount(ServerList list) => 0; + static IntPtr _GetName(ServerList list, int index) => IntPtr.Zero; + static IntPtr _GetAppName(ServerList list, int index) => IntPtr.Zero; + + #endif + #endregion } diff --git a/jp.keijiro.klak.syphon/Runtime/SyphonServerDirectory.cs b/jp.keijiro.klak.syphon/Runtime/SyphonServerDirectory.cs index dba15fe..42e89b6 100644 --- a/jp.keijiro.klak.syphon/Runtime/SyphonServerDirectory.cs +++ b/jp.keijiro.klak.syphon/Runtime/SyphonServerDirectory.cs @@ -10,7 +10,7 @@ public static IEnumerable EnumerateServerNames() { using var plugin = Interop.ServerList.Create(); var list = new List(); - for (var i = 0; i < plugin.Count; i++) + for (var i = 0; i < (plugin?.Count ?? 0); i++) { var (app, name) = (plugin.GetAppName(i), plugin.GetName(i)); list.Add(string.IsNullOrEmpty(name) ? app : $"{app}/{name}");