A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix: eliminate move gizmo double-write of UIRect offsets
esengine4dee964e43b4
diff --git a/editor/src/gizmos/builtinGizmos.ts b/editor/src/gizmos/builtinGizmos.tsindex 7c1c58e9f..25fc69a26 100644--- a/editor/src/gizmos/builtinGizmos.ts+++ b/editor/src/gizmos/builtinGizmos.ts@@ -83,21 +83,11 @@ export function createSelectGizmo(): GizmoDescriptor {// Move Gizmo// =============================================================================-interface UIRectDragInfo {- startOffsetMin: { x: number; y: number };- startOffsetMax: { x: number; y: number };- originalOffsetMin: { x: number; y: number };- originalOffsetMax: { x: number; y: number };- stretchedX: boolean;- stretchedY: boolean;-}-interface MoveGizmoDragState {startValue: { x: number; y: number; z: number };originalValue: { x: number; y: number; z: number };startWorldX: number;startWorldY: number;- uiRect: UIRectDragInfo | null;}export function createMoveGizmo(): GizmoDescriptor {@@ -191,29 +181,11 @@ export function createMoveGizmo(): GizmoDescriptor {const transform = entityData?.components.find(c => c.type === 'Transform');if (transform) {const value = transform.data.position as { x: number; y: number; z: number };- let uiRect: UIRectDragInfo | null = null;- const uiRectComp = entityData?.components.find(c => c.type === 'UIRect');- if (uiRectComp) {- const d = uiRectComp.data;- const anchorMin = d.anchorMin as { x: number; y: number };- const anchorMax = d.anchorMax as { x: number; y: number };- const offsetMin = d.offsetMin as { x: number; y: number };- const offsetMax = d.offsetMax as { x: number; y: number };- uiRect = {- startOffsetMin: { ...offsetMin },- startOffsetMax: { ...offsetMax },- originalOffsetMin: { ...offsetMin },- originalOffsetMax: { ...offsetMax },- stretchedX: anchorMin.x !== anchorMax.x,- stretchedY: anchorMin.y !== anchorMax.y,- };- }dragState = {startValue: { ...value },originalValue: { ...value },startWorldX: worldX,startWorldY: worldY,- uiRect,};}},@@ -238,23 +210,6 @@ export function createMoveGizmo(): GizmoDescriptor {newY = Math.round(newY / gridSize) * gridSize;}- if (dragState.uiRect) {- const effectiveDx = newX - dragState.startValue.x;- const effectiveDy = newY - dragState.startValue.y;- const ui = dragState.uiRect;-- gctx.store.updatePropertyDirect(entity, 'UIRect', 'offsetMin', {- x: ui.startOffsetMin.x + effectiveDx,- y: ui.startOffsetMin.y + effectiveDy,- });- if (ui.stretchedX || ui.stretchedY) {- gctx.store.updatePropertyDirect(entity, 'UIRect', 'offsetMax', {- x: ui.startOffsetMax.x + (ui.stretchedX ? effectiveDx : 0),- y: ui.startOffsetMax.y + (ui.stretchedY ? effectiveDy : 0),- });- }- }-gctx.store.updatePropertyDirect(entity, 'Transform', 'position', {x: newX, y: newY, z: dragState.startValue.z,});@@ -269,28 +224,7 @@ export function createMoveGizmo(): GizmoDescriptor {const transform = entityData?.components.find(c => c.type === 'Transform');if (transform) {const currentPos = transform.data.position;- const posChanged = currentPos && !valuesEqual(dragState.originalValue, currentPos);-- if (dragState.uiRect) {- const uiRectComp = entityData?.components.find(c => c.type === 'UIRect');- const curOffsetMin = uiRectComp?.data.offsetMin;- const curOffsetMax = uiRectComp?.data.offsetMax;- const ui = dragState.uiRect;- const changes: { componentType: string; property: string; oldValue: unknown; newValue: unknown }[] = [];-- if (curOffsetMin && !valuesEqual(ui.originalOffsetMin, curOffsetMin)) {- changes.push({ componentType: 'UIRect', property: 'offsetMin', oldValue: { ...ui.originalOffsetMin }, newValue: deepClone(curOffsetMin) });- }- if (curOffsetMax && !valuesEqual(ui.originalOffsetMax, curOffsetMax)) {- changes.push({ componentType: 'UIRect', property: 'offsetMax', oldValue: { ...ui.originalOffsetMax }, newValue: deepClone(curOffsetMax) });- }- if (posChanged) {- changes.push({ componentType: 'Transform', property: 'position', oldValue: { ...dragState.originalValue }, newValue: deepClone(currentPos) });- }- if (changes.length > 0) {- gctx.store.updateBatchProperties(entity, changes, 'Move UIRect entity');- }- } else if (posChanged) {+ if (currentPos && !valuesEqual(dragState.originalValue, currentPos)) {gctx.store.updateProperty(entity, 'Transform', 'position',{ ...dragState.originalValue }, deepClone(currentPos),