/// <inheritdoc/>
        public void OnPointerDown(MixedRealityPointerEventData eventData)
        {
            if (eventData.EventHandled || (!this.IncludeChildrenColliders && eventData.CurrentTarget != this.Owner))
            {
                return;
            }

            var cursor = eventData.Cursor;

            if (!this.activeCursors.ContainsKey(cursor))
            {
                this.activeCursors[cursor] = this.CreateCursorTransform(eventData);

                if (this.activeCursors.Count == 1)
                {
                    if (this.rigidBody != null && !this.KeepRigidBodyActiveDuringDrag)
                    {
                        this.previousLinearFactor  = this.rigidBody.LinearFactor;
                        this.previousAngularFactor = this.rigidBody.AngularFactor;

                        this.rigidBody.LinearFactor  = Vector3.Zero;
                        this.rigidBody.AngularFactor = Vector3.Zero;
                    }

                    this.ManipulationStarted?.Invoke(this, EventArgs.Empty);
                    AnyManipulationStarted?.Invoke(this, EventArgs.Empty);
                }

                eventData.SetHandled();
            }
        }
        /// <inheritdoc/>
        public void OnPointerDragged(MixedRealityPointerEventData eventData)
        {
            if (eventData.EventHandled)
            {
                return;
            }

            if (this.currentCursor == eventData.Cursor)
            {
                Vector3 delta = eventData.Position - this.grabbedCursorPosition;

                var deltaX = Vector3.Zero;
                var deltaY = Vector3.Zero;
                var deltaZ = Vector3.Zero;

                if (this.currentHandle.AxisType.HasFlag(AxisType.X))
                {
                    deltaX = Vector3.Project(delta, this.transform.WorldTransform.Right);
                }

                if (this.currentHandle.AxisType.HasFlag(AxisType.Y))
                {
                    deltaY = Vector3.Project(delta, this.transform.WorldTransform.Up);
                }

                if (this.currentHandle.AxisType.HasFlag(AxisType.Z))
                {
                    deltaZ = Vector3.Project(delta, this.transform.WorldTransform.Forward);
                }

                this.transform.Position = this.grabbedEntityPosition + deltaX + deltaY + deltaZ;

                eventData.SetHandled();
            }
        }
        /// <inheritdoc/>
        public void OnPointerDown(MixedRealityPointerEventData eventData)
        {
            if (eventData.EventHandled)
            {
                return;
            }

            if (this.currentCursor == null)
            {
                if (this.helpers.TryGetValue(eventData.CurrentTarget, out var handle))
                {
                    this.currentHandle = handle;

                    this.ApplyMaterialToHandle(this.currentHandle, h => h.GrabbedMaterial);

                    this.currentCursor         = eventData.Cursor;
                    this.grabbedEntityPosition = this.transform.Position;
                    this.grabbedCursorPosition = eventData.Position;

                    this.FireManipulationEvent(handle.Type, started: true);

                    eventData.SetHandled();
                }
            }
        }
        /// <inheritdoc/>
        public void OnPointerDragged(MixedRealityPointerEventData eventData)
        {
            if (eventData.EventHandled || (!this.IncludeChildrenColliders && eventData.CurrentTarget != this.Owner))
            {
                return;
            }

            var cursor = eventData.Cursor;

            if (this.activeCursors.ContainsKey(cursor))
            {
                this.activeCursors[cursor] = this.CreateCursorTransform(eventData);

                eventData.SetHandled();
            }
        }
        /// <inheritdoc/>
        public void OnPointerUp(MixedRealityPointerEventData eventData)
        {
            if (eventData.EventHandled)
            {
                return;
            }

            if (this.currentCursor == eventData.Cursor)
            {
                this.FireManipulationEvent(this.currentHandle.Type, started: false);

                this.ApplyMaterialToHandle(this.currentHandle, h => h.IdleMaterial);

                this.currentCursor = null;
                this.currentHandle = null;

                eventData.SetHandled();
            }
        }
示例#6
0
        /// <inheritdoc/>
        public void OnPointerUp(MixedRealityPointerEventData eventData)
        {
            if (eventData.EventHandled || (!this.IncludeChildrenColliders && eventData.CurrentTarget != this.Owner))
            {
                return;
            }

            var cursor = eventData.Cursor;

            if (this.activeCursors.Remove(cursor))
            {
                if (this.activeCursors.Count == 0)
                {
                    this.ReleaseRigidBody(eventData.LinearVelocity, eventData.AngularVelocity);

                    this.ManipulationEnded?.Invoke(this, EventArgs.Empty);
                }

                eventData.SetHandled();
            }
        }