// ------------------------------------------------------------------------ // Invoked whenever the SerialController gameobject is deactivated. // It stops and destroys the thread that was reading from the serial device. // ------------------------------------------------------------------------ public virtual void Shutdown() { // The serialThread reference should never be null at this point, // unless an Exception happened in the OnEnable(), in which case I've // no idea what face Unity will make. if (serialThread != null) { serialThread.RequestStop(); serialThread = null; } if (thread != null) { thread.Join(); thread = null; } }