PrimaryPointerInfo screenCoordinates/screenDelta use bottom-left Y-up instead of top-left Y-down
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Start in Explorer/Assets/DCL/SDKComponents/PrimaryPointerInfo/Systems/PrimaryPointerInfoSystem.cs at UpdatePointerInfo(), where inputPoint and Camera.Delta are assigned to ScreenCoordinates and ScreenDelta. Validate with the minimal SDK7 repro scene: the red square should stay under the cursor, and moving the mouse down should log a positive delta.y as in Bevy and Godot.
Written by the indexing model from the issue text.
Description
Summary
PrimaryPointerInfo.screenCoordinates and screenDelta are reported with a bottom-left origin / Y up (Unity's native screen space). Bevy and Godot report top-left origin / Y down, which is also the coordinate space of UiTransform / UiCanvasInformation. Scenes that compare the pointer against UI rects, or feed screenDelta into a VirtualCamera look, get a vertically mirrored cursor and inverted pitch on Unity only.
Where
Explorer/Assets/DCL/SDKComponents/PrimaryPointerInfo/Systems/PrimaryPointerInfoSystem.cs — UpdatePointerInfo() writes inputPoint.ReadValue<Vector2>() (Unity screen space, Y up) and the accumulated Camera.Delta straight into ScreenCoordinates / ScreenDelta.
For comparison:
- Bevy:
crates/scene_runner/src/update_scene/pointer_lock.rsusesWindow::cursor_position()(top-left, Y down) and the mouse-motion delta (Y down). - Godot:
lib/src/scene_runner/scene_manager.rsuses the viewport mouse position (top-left, Y down) and its frame difference.
The SDK docs specify a top-left origin with Y increasing downward, matching UiTransform. The proto comment only says "screen space (pixels)", so documenting the convention there too would help. Suggested fix: y = Screen.height - y for the position and negate delta.y.
This was reported for screenCoordinates in #8757 (closed by the stale bot, not fixed); this issue adds the screenDelta half and a repro scene.
How to validate
Minimal SDK7 scene: a 40x40 square follows the pointer using screenCoordinates in UI canvas space, and the log prints the delta sign while the pointer is locked.
import { engine, PrimaryPointerInfo, UiCanvasInformation, PointerLock } from '@dcl/sdk/ecs'
import ReactEcs, { ReactEcsRenderer, UiEntity } from '@dcl/sdk/react-ecs'
import { Color4 } from '@dcl/sdk/math'
export function main() {
ReactEcsRenderer.setUiRenderer(() => {
const cursor = PrimaryPointerInfo.getOrNull(engine.RootEntity)?.screenCoordinates
const canvas = UiCanvasInformation.getOrNull(engine.RootEntity)
if (!cursor || !canvas) return null
return (
<UiEntity
uiTransform={{
positionType: 'absolute',
position: { left: cursor.x - 20, top: cursor.y - 20 },
width: 40,
height: 40,
pointerFilter: 'none'
}}
uiBackground={{ color: Color4.Red() }}
/>
)
})
engine.addSystem(() => {
if (!PointerLock.getOrNull(engine.CameraEntity)?.isPointerLocked) return
const delta = PrimaryPointerInfo.getOrNull(engine.RootEntity)?.screenDelta
if (delta && Math.abs(delta.y) > 2) console.log(delta.y > 0 ? 'delta.y > 0' : 'delta.y < 0')
})
}
Expected (Bevy, Godot): the red square sits under the cursor; moving the mouse down logs delta.y > 0.
Actual (Unity): the square is mirrored vertically (top of screen when the cursor is at the bottom); moving the mouse down logs delta.y < 0.
- Dominant language
- C#
- Stars
- 23
- Forks
- 17
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 102
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from decentraland/unity-explorer
-
3-low bug documentation
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
decentraland/unity-explorer#10170 · 1 comment ·
-
3-low enhancement release
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
decentraland/unity-explorer#9978 · 1 comment ·
-
2-medium bug support ui
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
decentraland/unity-explorer#9538 · 2 comments ·
-
3-low bug ui
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
decentraland/unity-explorer#9530 · 3 comments ·
-
3-low stale tech debt
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
decentraland/unity-explorer#9150 · 2 comments ·
All issues in decentraland/unity-explorer
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·