/// <summary> /// Reset all of the variables that are included in the HandDataManager. /// </summary> public static void Reset() { OnNewCustomStreamHandData = null; deviceIDToPlayerIndex = new Dictionary <UInt64, int>(); playerData = new List <PlayerData>(); initialised = false; currentStreamType = DataStreamType.None; }
/// <summary> /// Prepare the HandDataManager class for use. /// This can safely be called multiple times; initialisation will occur only once. /// </summary> /// <param name="usePinchFilter">If the pinch filter should be used or not.</param> /// <param name="streamType">The type of data stream the manager will use.</param> public static void Initialise(DataStreamType streamType) { SwitchStreamType(streamType); if (initialised) { return; } Log("Starting the HandDataManager."); Application.runInBackground = true; initialised = true; }
/// <summary> /// Switch the stream type to another stream type. /// </summary> /// <param name="streamType">The new stream type that will be used.</param> public static void SwitchStreamType(DataStreamType streamType) { if (currentStreamType == streamType) { Log("Can not switch stream the stream type to " + streamType + " since the current stream type is already " + currentStreamType); return; } Apollo apollo = Apollo.GetInstance(UsePinchFilter); Log("The stream type is going to be switched to " + streamType); switch (streamType) { case DataStreamType.Apollo: // Subscribe to the Apollo stream apollo.RegisterDataListener(NewJointData); apollo.RegisterDataListener(NewRawData); // Unsubscribe from the custom stream OnNewCustomStreamHandData -= NewCustomData; break; case DataStreamType.Custom: // Subscribe to the custom stream OnNewCustomStreamHandData += NewCustomData; // Unsubscribe to the Apollo stream apollo.UnRegisterDataListener(NewJointData); apollo.UnRegisterDataListener(NewRawData); break; default: Log(streamType + " is not implemented as stream type"); break; } }