/// <summary> Check if a device manager is currently active within the Scene. If not, create an instance to manager our connection(s). </summary> protected void CheckForDeviceManager() { SG_DeviceManager manager = null; if (!SG_SenseGloveHardware.deviceScannerPresent) { object deviceManagerObj = GameObject.FindObjectOfType(typeof(SG_DeviceManager)); if (deviceManagerObj != null) //it exists { manager = (SG_DeviceManager)deviceManagerObj; if (!manager.isActiveAndEnabled || !manager.gameObject.activeInHierarchy) { Debug.LogWarning("WARNING: The SenseGlove_DeviceManager is not active in the scene. Objects will not connect until it is active."); } } else { GameObject newdeviceManager = new GameObject("[SG DeviceManager]"); manager = newdeviceManager.AddComponent <SG_DeviceManager>(); } SG_SenseGloveHardware.deviceScannerPresent = true; //we have either found it or created it. } else //it already exists { manager = (SG_DeviceManager)GameObject.FindObjectOfType(typeof(SG_DeviceManager)); } if (manager != null && this.autoConnect) //redundant check. { manager.AddToWatchList(this); //make sure this glove is added to its watchlist. } }
// Update is called once per frame void Update () { if (senseGlove.GloveReady) { if (!firstLink) { firstLink = true; baseInst = "Connected to " + senseGlove.GloveData.deviceID + " running firmware v" + senseGlove.GloveData.firmwareVersion; Instructions = baseInst; for (int i = 0; i < this.disableUntilFound.Length; i++) { this.disableUntilFound[i].SetActive(true); } } UpdateThumper(); UpdateDiagnostics(); //input if (SG_Util.keyBindsEnabled) { if (Input.GetKeyDown(toggleAllFFBKey)) { ToggleFFB(); } if (Input.GetKeyDown(toggleAllBuzzKey)) { ToggleBuzz(); } else if (Input.GetKeyDown(testThumperKey)) { BeginTestThumper(false); } else if (Input.GetKeyDown(fullLoadKey)) { ToggleAllFeedback(); } else if (Input.GetKeyDown(calibrateWristKey)) { this.CalibrateWrist(); } } } else //not yet linked { Instructions = SG_DeviceManager.ReportConnections(); } }