示例#1
0
        public void TransformWithinBounds()
        {
            UnityEventListenerMock transformedListenerMock = new UnityEventListenerMock();

            subject.Transformed.AddListener(transformedListenerMock.Listen);
            subject.SetPositiveBounds(new Vector2(0.3f, 0.8f));

            Assert.IsFalse(subject.Result);
            Assert.IsFalse(transformedListenerMock.Received);

            bool result = subject.Transform(0.5f);

            Assert.IsTrue(result);
            Assert.IsTrue(subject.Result);
            Assert.IsTrue(transformedListenerMock.Received);
        }
示例#2
0
        /// <summary>
        /// Sets the boundary data for the input.
        /// </summary>
        /// <param name="newBounds">Thew new range for the bounds.</param>
        /// <param name="deadzone">The axis deadzone to set.</param>
        /// <param name="positiveBounds">The axis positive bounds to set.</param>
        /// <param name="negativeBounds">The axis negative bounds to set.</param>
        /// <param name="boundsManager">The axis bounds manager to set.</param>
        protected virtual void SetBounds(FloatRange newBounds, FloatToBoolean[] deadzone, FloatToBoolean positiveBounds, FloatToBoolean negativeBounds, FloatToBoolean boundsManager)
        {
            foreach (FloatToBoolean zone in deadzone)
            {
                zone.SetPositiveBounds(newBounds.ToVector2());
            }

            positiveBounds.SetPositiveBounds(new Vector2(newBounds.maximum, 1f));
            negativeBounds.SetPositiveBounds(new Vector2(-1f, newBounds.minimum));
            boundsManager.SetPositiveBounds(new Vector2(Mathf.Max(-1f, newBounds.minimum - BoundOverlap), Mathf.Min(newBounds.maximum + BoundOverlap, 1f)));
        }