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]); } }
public override void Report(WebInterface.ACTION_BUTTON buttonId, Ray ray, HitInfo hit) { if (!enabled || !IsVisible()) { return; } Model pointerEventModel = this.model as Model; if (pointerEventModel == null) { return; } bool validButton = pointerEventModel.button == "ANY" || buttonId.ToString() == pointerEventModel.button; if (IsAtHoverDistance(hit.distance) && validButton) { string meshName = pointerEventHandler.GetMeshName(hit.collider); WebInterface.ReportOnPointerUpEvent(buttonId, scene.sceneData.id, pointerEventModel.uuid, entity.entityId, meshName, ray, hit.point, hit.normal, hit.distance); } }
void OnButtonEvent(WebInterface.ACTION_BUTTON buttonId, InputController_Legacy.EVENT evt, bool useRaycast) { //TODO(Brian): We should remove this when we get a proper initialization layer if (!EnvironmentSettings.RUNNING_TESTS) { if (Utils.LockedThisFrame()) { return; } if (!Utils.isCursorLocked || !renderingEnabled) { return; } } if (charCamera == null) { RetrieveCamera(); if (charCamera == null) { return; } } var pointerEventLayer = PhysicsLayers.physicsCastLayerMaskWithoutCharacter; //Ensure characterController is being filtered var globalLayer = pointerEventLayer & ~PhysicsLayers.physicsCastLayerMask; if (evt == InputController_Legacy.EVENT.BUTTON_DOWN) { ProcessButtonDown(buttonId, useRaycast, pointerEventLayer, globalLayer); } else if (evt == InputController_Legacy.EVENT.BUTTON_UP) { ProcessButtonUp(buttonId, useRaycast, pointerEventLayer, globalLayer); } }
void OnButtonEvent(WebInterface.ACTION_BUTTON buttonId, InputController_Legacy.EVENT evt, bool useRaycast) { if (!this.isTesting) { if (Utils.LockedThisFrame()) { return; } if (!Utils.isCursorLocked || renderingIsDisabled) { return; } } if (charCamera == null) { RetrieveCamera(); if (charCamera == null) { return; } } var pointerEventLayer = PhysicsLayers.physicsCastLayerMaskWithoutCharacter; //Ensure characterController is being filtered var globalLayer = pointerEventLayer & ~PhysicsLayers.physicsCastLayerMask; if (evt == InputController_Legacy.EVENT.BUTTON_DOWN) { ProcessButtonDown(buttonId, useRaycast, pointerEventLayer, globalLayer); } else if (evt == InputController_Legacy.EVENT.BUTTON_UP) { ProcessButtonUp(buttonId, useRaycast, pointerEventLayer, globalLayer); } }
public bool ShouldReportEvent(WebInterface.ACTION_BUTTON buttonId, HitInfo hit) { return(IsAtHoverDistance(hit.distance) && (model.button == "ANY" || buttonId.ToString() == model.button)); }
private void ProcessButtonDown(WebInterface.ACTION_BUTTON buttonId, bool useRaycast, LayerMask pointerEventLayer, int globalLayer) { RaycastHitInfo raycastGlobalLayerHitInfo; Ray ray = GetRayFromCamera(); // Raycast for pointer event components RaycastResultInfo raycastInfoPointerEventLayer = raycastHandler.Raycast(ray, charCamera.farClipPlane, pointerEventLayer, null); // Raycast for global pointer events RaycastResultInfo raycastInfoGlobalLayer = raycastHandler.Raycast(ray, charCamera.farClipPlane, globalLayer, null); raycastGlobalLayerHitInfo = raycastInfoGlobalLayer.hitInfo; bool isOnClickComponentBlocked = IsBlockingOnClick(raycastInfoPointerEventLayer.hitInfo, raycastGlobalLayerHitInfo); if (!isOnClickComponentBlocked && raycastInfoPointerEventLayer.hitInfo.hit.collider) { Collider collider = raycastInfoPointerEventLayer.hitInfo.hit.collider; GameObject hitGameObject; if (CollidersManager.i.GetColliderInfo(collider, out ColliderInfo info)) { hitGameObject = info.entity.gameObject; } else { hitGameObject = collider.gameObject; } OnClick onClick = hitGameObject.GetComponentInChildren <OnClick>(); if (AreSameEntity(onClick, info)) { onClick.Report(buttonId, raycastInfoPointerEventLayer.hitInfo.hit); } OnPointerDown onPointerDown = hitGameObject.GetComponentInChildren <OnPointerDown>(); if (IsAvatarPointerEvent(onPointerDown) || AreSameEntity(onPointerDown, info)) { onPointerDown.Report(buttonId, ray, raycastInfoPointerEventLayer.hitInfo.hit); } pointerUpEvent = hitGameObject.GetComponentInChildren <OnPointerUp>(); if (!AreSameEntity(pointerUpEvent, info)) { pointerUpEvent = null; } lastPointerDownEventHitInfo = raycastInfoPointerEventLayer.hitInfo; } string sceneId = SceneController.i.currentSceneId; if (useRaycast && raycastGlobalLayerHitInfo.isValid) { CollidersManager.i.GetColliderInfo(raycastGlobalLayerHitInfo.hit.collider, out ColliderInfo colliderInfo); WebInterface.ReportGlobalPointerDownEvent( 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.ReportGlobalPointerDownEvent(buttonId, raycastInfoGlobalLayer.ray, Vector3.zero, Vector3.zero, 0, sceneId); } }
public virtual void Report(WebInterface.ACTION_BUTTON buttonId, Ray ray, HitInfo hit) { }
private void ProcessButtonDown(WebInterface.ACTION_BUTTON buttonId, bool useRaycast, LayerMask pointerEventLayer, int globalLayer) { IWorldState worldState = Environment.i.world.state; RaycastHitInfo raycastGlobalLayerHitInfo; Ray ray = GetRayFromCamera(); // Raycast for pointer event components RaycastResultInfo raycastInfoPointerEventLayer = raycastHandler.Raycast(ray, charCamera.farClipPlane, pointerEventLayer, worldState.loadedScenes[worldState.currentSceneId]); // Raycast for global pointer events RaycastResultInfo raycastInfoGlobalLayer = raycastHandler.Raycast(ray, charCamera.farClipPlane, globalLayer, worldState.loadedScenes[worldState.currentSceneId]); raycastGlobalLayerHitInfo = raycastInfoGlobalLayer.hitInfo; bool isOnClickComponentBlocked = IsBlockingOnClick(raycastInfoPointerEventLayer.hitInfo, raycastGlobalLayerHitInfo); if (!isOnClickComponentBlocked && raycastInfoPointerEventLayer.hitInfo.hit.collider) { Collider collider = raycastInfoPointerEventLayer.hitInfo.hit.collider; GameObject hitGameObject; if (CollidersManager.i.GetColliderInfo(collider, out ColliderInfo info)) { hitGameObject = info.entity.gameObject; } else { hitGameObject = collider.gameObject; } var events = hitGameObject.GetComponentsInChildren <IPointerEvent>(); for (var i = 0; i < events.Length; i++) { IPointerEvent e = events[i]; bool areSameEntity = AreSameEntity(e, info); switch (e.GetEventType()) { case PointerEventType.CLICK: if (areSameEntity) { e.Report(buttonId, ray, raycastInfoPointerEventLayer.hitInfo.hit); } break; case PointerEventType.DOWN: if (areSameEntity) { e.Report(buttonId, ray, raycastInfoPointerEventLayer.hitInfo.hit); } break; case PointerEventType.UP: if (areSameEntity) { pointerUpEvent = e; } else { pointerUpEvent = null; } break; } } lastPointerDownEventHitInfo = raycastInfoPointerEventLayer.hitInfo; } ReportGlobalPointerDownEvent(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; ReportGlobalPointerDownEvent(buttonId, useRaycast, raycastGlobalLayerHitInfo, raycastInfoGlobalLayer, currentPortableExperienceIds[i]); } }
private void ProcessButtonDown(WebInterface.ACTION_BUTTON buttonId, bool useRaycast, LayerMask pointerEventLayer, int globalLayer) { IWorldState worldState = Environment.i.world.state; RaycastHitInfo raycastGlobalLayerHitInfo; Ray ray = GetRayFromCamera(); // Raycast for pointer event components RaycastResultInfo raycastInfoPointerEventLayer = raycastHandler.Raycast(ray, charCamera.farClipPlane, pointerEventLayer, worldState.loadedScenes[worldState.currentSceneId]); // Raycast for global pointer events RaycastResultInfo raycastInfoGlobalLayer = raycastHandler.Raycast(ray, charCamera.farClipPlane, globalLayer, worldState.loadedScenes[worldState.currentSceneId]); raycastGlobalLayerHitInfo = raycastInfoGlobalLayer.hitInfo; bool isOnClickComponentBlocked = IsBlockingOnClick(raycastInfoPointerEventLayer.hitInfo, raycastGlobalLayerHitInfo); if (!isOnClickComponentBlocked && raycastInfoPointerEventLayer.hitInfo.hit.collider) { Collider collider = raycastInfoPointerEventLayer.hitInfo.hit.collider; GameObject hitGameObject; if (CollidersManager.i.GetColliderInfo(collider, out ColliderInfo info)) { hitGameObject = info.entity.gameObject; } else { hitGameObject = collider.gameObject; } OnClick onClick = hitGameObject.GetComponentInChildren <OnClick>(); if (AreSameEntity(onClick, info)) { onClick.Report(buttonId, raycastInfoPointerEventLayer.hitInfo.hit); } OnPointerDown onPointerDown = hitGameObject.GetComponentInChildren <OnPointerDown>(); if (IsAvatarPointerEvent(onPointerDown) || AreSameEntity(onPointerDown, info)) { onPointerDown.Report(buttonId, ray, raycastInfoPointerEventLayer.hitInfo.hit); } pointerUpEvent = hitGameObject.GetComponentInChildren <OnPointerUp>(); if (!AreSameEntity(pointerUpEvent, info)) { pointerUpEvent = null; } lastPointerDownEventHitInfo = raycastInfoPointerEventLayer.hitInfo; } ReportGlobalPointerDownEvent(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; ReportGlobalPointerDownEvent(buttonId, useRaycast, raycastGlobalLayerHitInfo, raycastInfoGlobalLayer, currentPortableExperienceIds[i]); } }