public void startSharing() { Instance = this; this.logWriter = new ConsoleLogWriter(); ClientConfig config = new ClientConfig(this.ClientRole); config.SetIsAudioEndpoint(this.IsAudioEndpoint); config.SetLogWriter(this.logWriter); config.SetServerAddress(this.ServerAddress); config.SetServerPort(this.ServerPort); this.xtoolsMgr = XToolsManager.Create(config); }
protected void OnDestroy() { Instance = null; // Force a disconnection so that we can stop and start Unity without connections hanging around this.xtoolsMgr.GetPairedConnection().Disconnect(); this.xtoolsMgr.GetServerConnection().Disconnect(); // Release the XTools manager so that it cleans up the C++ copy this.xtoolsMgr.Dispose(); this.xtoolsMgr = null; // Forces a garbage collection to try to clean up any additional reference to SWIG-wrapped objects System.GC.Collect(); }