コード例 #1
0
        private void ProcessButtonUp(WebInterface.ACTION_BUTTON buttonId, bool useRaycast, LayerMask pointerEventLayer, int globalLayer)
        {
            RaycastHitInfo raycastGlobalLayerHitInfo;
            Ray            ray = GetRayFromCamera();

            // Raycast for global pointer events
            RaycastResultInfo raycastInfoGlobalLayer = raycastHandler.Raycast(ray, charCamera.farClipPlane, globalLayer, null);

            raycastGlobalLayerHitInfo = raycastInfoGlobalLayer.hitInfo;

            if (pointerUpEvent != null)
            {
                // Raycast for pointer event components
                RaycastResultInfo raycastInfoPointerEventLayer = raycastHandler.Raycast(ray, charCamera.farClipPlane, pointerEventLayer, null);

                bool isOnClickComponentBlocked  = IsBlockingOnClick(raycastInfoPointerEventLayer.hitInfo, raycastGlobalLayerHitInfo);
                bool isSameEntityThatWasPressed = AreCollidersFromSameEntity(raycastInfoPointerEventLayer.hitInfo, lastPointerDownEventHitInfo);

                if (!isOnClickComponentBlocked && isSameEntityThatWasPressed)
                {
                    bool isHitInfoValid = raycastInfoPointerEventLayer.hitInfo.hit.collider != null;
                    pointerUpEvent.Report(buttonId, ray, raycastInfoPointerEventLayer.hitInfo.hit, isHitInfoValid);
                }

                pointerUpEvent = null;
            }

            string sceneId = SceneController.i.currentSceneId;

            if (useRaycast && raycastGlobalLayerHitInfo.isValid)
            {
                CollidersManager.i.GetColliderInfo(raycastGlobalLayerHitInfo.hit.collider, out ColliderInfo colliderInfo);

                WebInterface.ReportGlobalPointerUpEvent(
                    buttonId,
                    raycastInfoGlobalLayer.ray,
                    raycastGlobalLayerHitInfo.hit.point,
                    raycastGlobalLayerHitInfo.hit.normal,
                    raycastGlobalLayerHitInfo.hit.distance,
                    sceneId,
                    colliderInfo.entity != null ? colliderInfo.entity.entityId : null,
                    colliderInfo.meshName,
                    isHitInfoValid: true);
            }
            else
            {
                WebInterface.ReportGlobalPointerUpEvent(buttonId, raycastInfoGlobalLayer.ray, Vector3.zero, Vector3.zero, 0, sceneId);
            }
        }
コード例 #2
0
        private void HitFirst(RaycastQuery query)
        {
            WebInterface.RaycastHitEntity hitEntity;

            ParcelScene scene;

            SceneController.i.TryGetScene(query.sceneId, out scene);

            RaycastResultInfo raycastInfo = raycastHandler.Raycast(GetUnityRayFromQuery(query), query.ray.distance, ~layerMaskTarget, scene);

            WebInterface.RayInfo rayInfo = GetRayInfoFromQuery(query);

            if (raycastInfo != null)
            {
                CollidersManager.i.GetColliderInfo(raycastInfo.hitInfo.hit.collider, out ColliderInfo colliderInfo);

                hitEntity = new WebInterface.RaycastHitEntity()
                {
                    didHit    = raycastInfo.hitInfo.isValid,
                    hitNormal = raycastInfo.hitInfo.hit.normal,
                    hitPoint  = raycastInfo.hitInfo.hit.point,
                    ray       = rayInfo,
                    entity    = new WebInterface.HitEntityInfo()
                    {
                        entityId = colliderInfo.entity != null ? colliderInfo.entity.entityId : null,
                        meshName = colliderInfo.meshName
                    }
                };
            }
            else
            {
                hitEntity = new WebInterface.RaycastHitEntity()
                {
                    didHit = false,
                    ray    = rayInfo
                };
            }

            WebInterface.ReportRaycastHitFirstResult(query.sceneId, query.queryId, query.queryType, hitEntity);
        }
コード例 #3
0
        private void ProcessButtonUp(WebInterface.ACTION_BUTTON buttonId, bool useRaycast, LayerMask pointerEventLayer, int globalLayer)
        {
            IWorldState    worldState = Environment.i.world.state;
            RaycastHitInfo raycastGlobalLayerHitInfo;
            Ray            ray = GetRayFromCamera();

            // Raycast for global pointer events
            RaycastResultInfo raycastInfoGlobalLayer = raycastHandler.Raycast(ray, charCamera.farClipPlane, globalLayer, worldState.loadedScenes[worldState.currentSceneId]);

            raycastGlobalLayerHitInfo = raycastInfoGlobalLayer.hitInfo;

            if (pointerUpEvent != null)
            {
                // Raycast for pointer event components
                RaycastResultInfo raycastInfoPointerEventLayer = raycastHandler.Raycast(ray, charCamera.farClipPlane, pointerEventLayer, worldState.loadedScenes[worldState.currentSceneId]);

                bool isOnClickComponentBlocked  = IsBlockingOnClick(raycastInfoPointerEventLayer.hitInfo, raycastGlobalLayerHitInfo);
                bool isSameEntityThatWasPressed = AreCollidersFromSameEntity(raycastInfoPointerEventLayer.hitInfo, lastPointerDownEventHitInfo);

                if (!isOnClickComponentBlocked && isSameEntityThatWasPressed)
                {
                    bool isHitInfoValid = raycastInfoPointerEventLayer.hitInfo.hit.collider != null;
                    pointerUpEvent.Report(buttonId, ray, raycastInfoPointerEventLayer.hitInfo.hit, isHitInfoValid);
                }

                pointerUpEvent = null;
            }

            ReportGlobalPointerUpEvent(buttonId, useRaycast, raycastGlobalLayerHitInfo, raycastInfoGlobalLayer, worldState.currentSceneId);

            // Raycast for global pointer events (for each PE scene)
            List <string> currentPortableExperienceIds = WorldStateUtils.GetActivePortableExperienceIds();

            for (int i = 0; i < currentPortableExperienceIds.Count; i++)
            {
                raycastInfoGlobalLayer    = raycastHandler.Raycast(ray, charCamera.farClipPlane, globalLayer, worldState.loadedScenes[currentPortableExperienceIds[i]]);
                raycastGlobalLayerHitInfo = raycastInfoGlobalLayer.hitInfo;

                ReportGlobalPointerUpEvent(buttonId, useRaycast, raycastGlobalLayerHitInfo, raycastInfoGlobalLayer, currentPortableExperienceIds[i]);
            }
        }