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