예제 #1
0
        /// <summary>
        /// Unsubscribes from manipulation events.
        /// </summary>
        private void OnDisable()
        {
            if (objectManipulator != null)
            {
                objectManipulator.OnManipulationStarted.RemoveListener(OnManipulationStarted);
                objectManipulator.OnManipulationEnded.RemoveListener(OnManipulationEnded);

                objectManipulator = null;
            }

            if (manipulationHandler != null)
            {
                manipulationHandler.OnManipulationStarted.RemoveListener(OnManipulationStarted);
                manipulationHandler.OnManipulationEnded.RemoveListener(OnManipulationEnded);

                manipulationHandler = null;
            }

            if (dockedPosition != null)
            {
                dockedPosition.DockedObject = null;
                dockedPosition = null;
            }

            overlappingPositions.Clear();
        }
예제 #2
0
        private void Start()
        {
            objectManipulator = GetComponent <ObjectManipulator>();

            contextInfo = gameObject.EnsureComponent <CursorContextInfo>();
            contextInfo.ObjectCenter = transform;

            objectManipulator.OnHoverEntered.AddListener(ManipulatorHoverEntered);
            objectManipulator.OnHoverExited.AddListener(ManipulatorHoverExited);
            objectManipulator.OnManipulationStarted.AddListener(ManipulationStarted);
            objectManipulator.OnManipulationEnded.AddListener(ManipulationEnded);
        }
예제 #3
0
        /// <summary>
        /// Subscribes to manipulation events.
        /// </summary>
        private void OnEnable()
        {
            objectManipulator = gameObject.GetComponent <ObjectManipulator>();
            if (objectManipulator != null)
            {
                objectManipulator.OnManipulationStarted.AddListener(OnManipulationStarted);
                objectManipulator.OnManipulationEnded.AddListener(OnManipulationEnded);
            }
            else
            {
                manipulationHandler = gameObject.GetComponent <ManipulationHandler>();
                if (manipulationHandler != null)
                {
                    manipulationHandler.OnManipulationStarted.AddListener(OnManipulationStarted);
                    manipulationHandler.OnManipulationEnded.AddListener(OnManipulationEnded);
                }
            }

            Assert.IsTrue(objectManipulator != null || manipulationHandler != null,
                          "A Dockable object must have either an ObjectManipulator or a ManipulationHandler component.");

            Assert.IsNotNull(gameObject.GetComponent <Collider>(), "A Dockable object must have a Collider component.");
        }