kshoji / Unity-MIDI-Plugin-supports

Documents and issues for Unity MIDI Plugin
9 stars 0 forks source link

Is this project still active? Have errors with sample scene #11

Open gegagome opened 1 year ago

gegagome commented 1 year ago

Can you please let me and others know if you are updating this asset or if its no longer active? I am sure others would also like to know to decide how to move on with their projects.

Are you aware of the problems we are running into with your asset? Its a great asset however it doesnt work consistently and is throwing some errors.

For instance this problem is also a problem others have been positing about here and the reviews section of the asset store and that is the issue where MIDI devices work fine but then when you restart the editor they dont. And it happens randomly, Unity registers my MIDI keyboard events just fine but then after compiling for whatever change I need to make the same MIDI keyboards just wont register the same events with the same code. So weird.

Besides that I have these errors:

#if !UNITY_IOS && !UNITY_WEBGL
                    var ipEntry = Dns.GetHostEntry(Dns.GetHostName());

that log: SocketException: Could not resolve host 'Computer NAME' System.Net.Dns.Error_11001 (System.String hostName) (at <2fe115660d9c47728edff248f3625297>:0) System.Net.Dns.GetHostByName (System.String hostName) (at <2fe115660d9c47728edff248f3625297>:0) System.Net.Dns.GetHostEntry (System.String hostNameOrAddress) (at <2fe115660d9c47728edff248f3625297>:0) jp.kshoji.unity.midi.sample.MidiSampleScene.OnGUIWindow (System.Int32 id) (at Assets/MIDI/Samples/Scripts/MidiSampleScene.cs:375) UnityEngine.GUILayout+LayoutedWindow.DoWindow (System.Int32 windowID) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUILayout.cs:444) UnityEngine.GUI.CallWindowDelegate (UnityEngine.GUI+WindowFunction func, System.Int32 id, System.Int32 instanceID, UnityEngine.GUISkin _skin, System.Int32 forceRect, System.Single width, System.Single height, UnityEngine.GUIStyle style) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUI.cs:1914) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)

AND

InvalidOperationException: The following game object is invoking the DontDestroyOnLoad method: MidiManager. Notice that DontDestroyOnLoad can only be used in play mode and, as such, cannot be part of an editor script. jp.kshoji.unity.midi.MidiManager.get_Instance () (at Assets/MIDI/Scripts/MidiManager.cs:229) jp.kshoji.unity.midi.MidiManager+<>c.b__88_0 (System.Object o) (at Assets/MIDI/Scripts/MidiManager.cs:2646) UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at /Users/bokken/buildslave/unity/build/Runtime/Export/Scripting/UnitySynchronizationContext.cs:153) UnityEngine.UnitySynchronizationContext.Exec () (at /Users/bokken/buildslave/unity/build/Runtime/Export/Scripting/UnitySynchronizationContext.cs:83) UnityEngine.UnitySynchronizationContext.ExecuteTasks () (at /Users/bokken/buildslave/unity/build/Runtime/Export/Scripting/UnitySynchronizationContext.cs:107)

hsallander commented 1 year ago

I don't think it's active anymore. We've had multiple breaking problems with this plugin and we've had to patch things up ourselves. I've reported issues in this tracker but never got a response from the developer.

gegagome commented 1 year ago

I don't think it's active anymore. We've had multiple breaking problems with this plugin and we've had to patch things up ourselves. I've reported issues in this tracker but never got a response from the developer.

What did you do to fix it? Is it something you can share?

kshoji commented 1 year ago

The SocketException thrown code is for getting local IP Addresses. And this code will throw an exception in some network environments.

var ipEntry = Dns.GetHostEntry(Dns.GetHostName());

This code is a utility, and not mandatory for sample scene's feature. If you can know the IP address in some other way, just comment out this code block.

kshoji commented 1 year ago

Changing ipEntry code block to the follows, the SocketException may fixed.

                    foreach (var netInterface in NetworkInterface.GetAllNetworkInterfaces())
                    {
                        var properties = netInterface.GetIPProperties();
                        foreach (var unicast in properties.UnicastAddresses)
                        {
                            var address = unicast.Address;
                            if (address.IsIPv6LinkLocal || address.IsIPv6Multicast || address.IsIPv6SiteLocal || address.IsIPv4MappedToIPv6 || address.IsIPv6Teredo)
                            {
                                continue;
                            }
                            if (address.AddressFamily != AddressFamily.InterNetwork && address.AddressFamily != AddressFamily.InterNetworkV6)
                            {
                                continue;
                            }
                            if (IPAddress.IsLoopback(address))
                            {
                                continue;
                            }
                            GUILayout.BeginHorizontal();
                            GUILayout.Label(address.ToString());
                            if (GUILayout.Button("Copy to clipboard"))
                            {
                                GUIUtility.systemCopyBuffer = address.ToString();
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
kshoji commented 1 year ago

I couldn't confirm InvalidOperationException thrown, it seems to be solved by changing the code of MidiManager as follows.

Change the part of MidiManager Instance getter (line 229 at MidiManager.cs )

from

DontDestroyOnLoad(instance);

to

#if !UNITY_EDITOR
DontDestroyOnLoad(instance);
#endif