Beispiel #1
0
        /// <summary>
        /// To be called at the start of an Interaction Engine test. Loads the named object
        /// by finding it in the current scene or otherwise by spawning it by prefab name.
        ///
        /// After calling this method, the following fields are set:
        ///
        /// PROVIDERS
        /// - testProvider: The LeapProvider designed for IE unit tests.
        ///
        /// MANAGERS
        /// - manager: The Interaction Manager.
        ///
        /// CONTROLLERS
        /// - leftHand: The left Interaction Hand, if there is one.
        /// - rightHand: The right Interaction Hand, if there is one.
        /// - leftVRController: The left VR controller, if there is one.
        /// - rightVRController: The right VR Controller, if there is one.
        ///
        /// OBJECTS
        /// - box0: An InteractionBehaviour with an attached BoxCollider, if there is one.
        /// - box1: Another InteractionBehaviour with an attached BoxCollider, if it exists.
        /// - box2: Yet another InteractionBehaviour with a BoxCollider, if it exists.
        /// </summary>
        protected override void InitTest(string objectName)
        {
            base.InitTest(objectName);

            testProvider = testObj.GetComponentInChildren <StationaryTestLeapProvider>();

            manager = testObj.GetComponentInChildren <InteractionManager>();

            foreach (var controller in manager.interactionControllers)
            {
                if (controller.intHand != null && controller.isLeft)
                {
                    leftHand = controller.intHand;
                    continue;
                }
                if (controller.intHand != null && !controller.isLeft)
                {
                    rightHand = controller.intHand;
                    continue;
                }

                var vrController = controller as InteractionVRController;
                if (vrController != null && vrController.isLeft)
                {
                    leftVRController = vrController;
                    continue;
                }
                if (vrController != null && !vrController.isLeft)
                {
                    rightVRController = vrController;
                    continue;
                }
            }

            var intObjs = Pool <List <InteractionBehaviour> > .Spawn();

            try {
                testObj.GetComponentsInChildren <InteractionBehaviour>(true, intObjs);

                // Load "simple box" interaction objects.
                foreach (var simpleBoxObj in intObjs.Query().Where(o => o.primaryHoverColliders.Count == 1 &&
                                                                   o.primaryHoverColliders[0] is BoxCollider))
                {
                    if (box0 == null)
                    {
                        box0 = simpleBoxObj; continue;
                    }
                    if (box1 == null)
                    {
                        box1 = simpleBoxObj; continue;
                    }
                    if (box2 == null)
                    {
                        box2 = simpleBoxObj; continue;
                    }
                }
            }
            finally {
                intObjs.Clear();
                Pool <List <InteractionBehaviour> > .Recycle(intObjs);
            }
        }
        /// <summary>
        /// Call this at the start of an Interaction engine test with the name of a stage
        /// object and the name of a rig object to load those objects and fill utility
        /// parameters such as manager, leftHand, box0, etc. for testing.
        /// </summary>
        protected void InitTest(string rigObjName, string stageObjName)
        {
            // Load test rig objects.
            base.InitTest(rigObjName);
            rigObj    = testObj;
            recording = rigObj.GetComponentInChildren <PlayableDirector>();
            provider  = rigObj.GetComponentInChildren <LeapProvider>();
            manager   = rigObj.GetComponentInChildren <InteractionManager>();

            foreach (var controller in manager.interactionControllers)
            {
                if (controller.intHand != null && controller.isLeft)
                {
                    leftHand = controller.intHand;
                    continue;
                }
                if (controller.intHand != null && !controller.isLeft)
                {
                    rightHand = controller.intHand;
                    continue;
                }

                var vrController = controller as InteractionVRController;
                if (vrController != null && vrController.isLeft)
                {
                    leftVRController = vrController;
                    continue;
                }
                if (vrController != null && !vrController.isLeft)
                {
                    rightVRController = vrController;
                    continue;
                }
            }

            // Load stage objects.
            stageObj = LoadObject(stageObjName);

            var intObjs = Pool <List <InteractionBehaviour> > .Spawn();

            try {
                stageObj.GetComponentsInChildren <InteractionBehaviour>(true, intObjs);

                // Load "simple box" interaction objects.
                foreach (var simpleBoxObj in intObjs.Query().Where(o => o.primaryHoverColliders.Count == 1 &&
                                                                   o.primaryHoverColliders[0] is BoxCollider))
                {
                    if (box0 == null)
                    {
                        box0 = simpleBoxObj; continue;
                    }
                    if (box1 == null)
                    {
                        box1 = simpleBoxObj; continue;
                    }
                    if (box2 == null)
                    {
                        box2 = simpleBoxObj; continue;
                    }
                }
            }
            finally {
                intObjs.Clear();
                Pool <List <InteractionBehaviour> > .Recycle(intObjs);
            }
        }