Game (unity3d) with phidgets hangs on close

Supporting Visual Studio on Windows
Post Reply
Mr12Fingers
Fresh meat
Posts: 1
Joined: Sat Oct 08, 2022 1:46 pm
Contact:

Re: Game (unity3d) with phidgets hangs on close

Post by Mr12Fingers »

I'm still having issues with the dll crashing Unity in the Editor. Sometimes it will crash immediately after I exit Play mode. Other times it will exit cleanly but then crash the next time I hit play. If during Play Unity throws an error, it will crash every time. This obviously makes development extremely painful and slow. I tried using the exit code from this thread but it only works sometimes. I'm using Phidget22(dot)NET 1(dot)dll.

Here is most of the relevant code:

Code: Select all

#if (UNITY_EDITOR) 
			EditorPlayMode.PlayModeChanged += OnPlayModeChanged;
		#endif
		phidget=new RFID();
	    //  Phidget.HubPort = 64617;
	    phidget.Channel = 0;
	    
		phidget.Tag += phidget_Tag;
		phidget.Open(Phidget.DefaultTimeout);


	private void OnPlayModeChanged(PlayModeState currentMode, PlayModeState changedMode)
	{
			// DO your stuff here...
			Debug.Log(currentMode.ToString() + " => " + changedMode.ToString());
		if(changedMode.ToString()=="AboutToStop"){
			OnApplicationQuit();
		}
		
		#if (UNITY_EDITOR)
			if (debugOp) {
				Debug.Log(EditorApplication.isCompiling);
				Debug.Log(EditorApplication.isPaused);
				Debug.Log(EditorApplication.isPlaying);
				Debug.Log(EditorApplication.isPlayingOrWillChangePlaymode);
				Debug.Log(EditorApplication.isUpdating);
				Debug.LogWarning("-------------------------------------");
			}
			
		#endif
		
	}


	void OnApplicationQuit()
	{
		Debug.Log("QUITTING APPLICATION");
		if (Application.isEditor)
			Phidget.ResetLibrary();
		else
			Phidget.FinalizeLibrary(0);
	}

Any help would be appreciated.

-Mr12
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests