Exemplo n.º 1
0
        private void Awake()
        {
            _wearableControl = WearableControl.Instance;

            // Establish a requirement for the referenced gesture.
            _requirement = gameObject.AddComponent <WearableRequirement>();
        }
Exemplo n.º 2
0
        private void Awake()
        {
            _mode             = RotationReference.Absolute;
            _inverseReference = Quaternion.identity;
            _requirement      = null;
            _wearableControl  = WearableControl.Instance;

            CheckAndResolveRequirement();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Check that the required rotation sensor is enabled and rate is sufficient, resolve differences if not.
        /// Adds a <see cref="WearableRequirement"/> component on this GameObject if needed.
        /// </summary>
        private void CheckAndResolveRequirement()
        {
            bool showChangedRequirementWarnings = true;

            if (_requirement == null)
            {
                // If we don't have a requirement, look for one on the parent GameObject.
                _requirement = GetComponent <WearableRequirement>();
                if (_requirement == null)
                {
                    // If there isn't one, create it.
                    _requirement = gameObject.AddComponent <WearableRequirement>();
                    Debug.LogFormat(WearableConstants.ROTATION_MATCHER_ADDED_REQUIREMENT_MESSAGE_FORMAT, name);

                    // If it's a new requirement, suppress the alteration warnings.
                    showChangedRequirementWarnings = false;
                }
            }

            // Check that the attached requirement's update interval is fast enough.
            if (_requirement.DeviceConfig.updateInterval.IsSlowerThan(_updateInterval))
            {
                _requirement.SetSensorUpdateInterval(_updateInterval);
                if (showChangedRequirementWarnings)
                {
                    Debug.LogWarningFormat(
                        WearableConstants.ROTATION_MATCHER_CHANGED_REQUIREMENT_UPDATE_INTERVAL_WARNING_FORMAT,
                        name);
                }
            }

            // Check to ensure the proper sensor is enabled
            SensorId rotationSensorId = _rotationSource == RotationSensorSource.NineDof ?
                                        SensorId.RotationNineDof :
                                        SensorId.RotationSixDof;
            var config = _requirement.DeviceConfig.GetSensorConfig(rotationSensorId);

            if (!config.isEnabled)
            {
                // Switch to proper sensor and turn off the unused one.
                // If the user has manually enabled both sensors, this will not turn any sensors off when changing mode.
                _requirement.EnableSensor(rotationSensorId);
                _requirement.DisableSensor(
                    rotationSensorId == SensorId.RotationSixDof ?
                    SensorId.RotationNineDof :
                    SensorId.RotationSixDof);

                if (showChangedRequirementWarnings)
                {
                    Debug.LogWarningFormat(
                        WearableConstants.ROTATION_MATCHER_CHANGED_REQUIREMENT_SENSORS_WARNING_FORMAT,
                        name);
                }
            }
        }
Exemplo n.º 4
0
        private void Awake()
        {
            _wearableControl = WearableControl.Instance;
            _wearableControl.GestureDetected += GestureDetected;

            // Establish a requirement for the referenced gesture.
            _requirement = gameObject.AddComponent <WearableRequirement>();

            if (_gesture != GestureId.None)
            {
                _requirement.EnableGesture(_gesture);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Unregisters the <see cref="WearableRequirement"/> <paramref name="requirement"/>
        /// </summary>
        /// <param name="requirement"></param>
        internal void UnregisterRequirement(WearableRequirement requirement)
        {
            if (!_wearableRequirements.Contains(requirement))
            {
                return;
            }

            requirement.Updated -= LockDeviceStateUpdate;

            _wearableRequirements.Remove(requirement);

            LockDeviceStateUpdate();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Registers the <see cref="WearableRequirement"/> <paramref name="requirement"/>
        /// </summary>
        /// <param name="requirement"></param>
        internal void RegisterRequirement(WearableRequirement requirement)
        {
            if (_wearableRequirements.Contains(requirement))
            {
                return;
            }

            requirement.Updated += LockDeviceStateUpdate;

            _wearableRequirements.Add(requirement);

            LockDeviceStateUpdate();
        }
Exemplo n.º 7
0
        private void Awake()
        {
            // Begin in absolute mode and cache the wearable controller.
            _wearableControl = WearableControl.Instance;


            // Establish a requirement for the rotation sensor
            WearableRequirement requirement = GetComponent <WearableRequirement>();

            if (requirement == null)
            {
                requirement = gameObject.AddComponent <WearableRequirement>();
            }

            requirement.EnableSensor(SensorId.Accelerometer);
            requirement.SetSensorUpdateInterval(SensorUpdateInterval.EightyMs);
        }
Exemplo n.º 8
0
        private void Awake()
        {
            // Begin in absolute mode and cache the wearable controller.
            _wearableControl  = WearableControl.Instance;
            _mode             = RotationReference.Absolute;
            _inverseReference = Quaternion.identity;

            // Establish a requirement for the rotation sensor
            WearableRequirement requirement = GetComponent <WearableRequirement>();

            if (requirement == null)
            {
                requirement = gameObject.AddComponent <WearableRequirement>();
            }
            requirement.EnableSensor(SensorId.Rotation);
            requirement.SetSensorUpdateInterval(SensorUpdateInterval.EightyMs);
        }