Код: Выделить всё
public void OnMouseClickPerformed(InputAction.CallbackContext context)
{
if (!context.started)
return;
Vector3 mousePos;
if (TouchSimulation.instance.isActiveAndEnabled)
mousePos = Touchscreen.current.position.ReadValue();
else
mousePos = Mouse.current.position.ReadValue();
Debug.Log($"Click Pos: {mousePos}");
int gameplayLayerMask = LayerMask.GetMask("Default");
RaycastHit2D hit = Physics2D.GetRayIntersection(mainCamera.ScreenPointToRay(mousePos), Mathf.Infinity, gameplayLayerMask);
if (hit.collider != null)
{
Debug.Log($"{hit.collider.gameObject.name}");
HandleInteractableObject(hit.collider.gameObject);
}
}
< /code>
Это также работает самостоятельно. В игре и в симуляторе проблема в том, что он не работает, когда компонент «на экране» активен на любой из ранее упомянутых кнопок. Я пытался создать маски и разделить камеры и все такое. Я добавил Debug.log Подробнее здесь: https://stackoverflow.com/questions/797 ... -is-active
Мобильная версия