Skip to content

Conversation

@hwcctn
Copy link

@hwcctn hwcctn commented Sep 9, 2025

No description provided.

@hwcctn
Copy link
Author

hwcctn commented Sep 9, 2025

@nighca 老师提交了一个新的pr,之前的分支有点问题。我弄了一个新的

value: string;
x: number;
y: number;
width: number;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这次还会支持自定义每个 button 的大小吗?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,可以自动设置大小

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥考虑支持自定义的 button 大小?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥考虑支持自定义的 button 大小?

这个主要是参考共创世界的那个键盘配置。然后感觉也是合理的,可以让他们在这一块更多选择。如果不想选择的话,也可以使用系统默认的。老师可能感觉这个功能没太必要吗?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我是担心我们允许的自定义多了反而会导致我们自己难做

举个例子,如果我们允许每个 button 自定义大小 & 位置;但是我们知道不同手机设备屏幕大小、比例是不同的,而游戏本身渲染区域的比例目前是固定的,那么怎么做到:既满足用户自定义的 button 大小、位置,又尽量让 button 不遮挡游戏渲染区域(如果遮挡的话显然可能会影响游戏体验),就很难

我们允许自定义的东西越少,最终界面上的元素数量、占据的面积、位置的确定性越高,上面这件事情我们就越容易做

Copy link
Collaborator

@nighca nighca Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这边倒是会引出另外一个问题:目前 btn 上的 posX、posY 都是相对屏幕左上角(或者左下)的偏移量吗?是的话,如果开发者配了 posX: 500, posY: 1000,但是最终用户的手机屏幕宽高甚至小于 500/1000,那按钮就不可见了?

如果开发者希望某个按键就贴着屏幕右下角,不论最终用户的设备分辨率是多大(这个应该是正常的诉求),他能达到目的吗

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我是担心我们允许的自定义多了反而会导致我们自己难做

举个例子,如果我们允许每个 button 自定义大小 & 位置;但是我们知道不同手机设备屏幕大小、比例是不同的,而游戏本身渲染区域的比例目前是固定的,那么怎么做到:既满足用户自定义的 button 大小、位置,又尽量让 button 不遮挡游戏渲染区域(如果遮挡的话显然可能会影响游戏体验),就很难

我们允许自定义的东西越少,最终界面上的元素数量、占据的面积、位置的确定性越高,上面这件事情我们就越容易做

明白了,那这个功能现阶段先不做这一块,后续如果有更成熟的适配方案或确有必要,再开放更灵活的自定义。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这边倒是会引出另外一个问题:目前 btn 上的 posX、posY 都是相对屏幕左上角(或者左下)的偏移量吗?是的话,如果开发者配了 posX: 500, posY: 1000,但是最终用户的手机屏幕宽高甚至小于 500/1000,那按钮就不可见了?

如果开发者希望某个按键就贴着屏幕右下角,不论最终用户的设备分辨率是多大(这个应该是正常的诉求),他能达到目的吗

是的,这一块确实是问题,我感觉我可能要调研一下这一块的相关技术,比如用百分比定位?或者看看有没有一些算法可以,获取到每个手机的分辨率,然后通过和设计图(默认)进行映射转化这类方案?老师有没有什么建议

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我感觉我可能要调研一下这一块的相关技术

嗯可以去了解一下,我也了解不多

百分比定位是个做法;也可以考虑对屏幕进行分区,比如左上、右上、左下、右下四个区,每个区都相对各自的角落进行定位

企业微信截图_e5518b68-9547-4749-a5ce-5c759942eb1b

比如这个是 Unity 对 UI 元素进行布局的界面,可以选择定位的参考点,当然它这个比较复杂了

/** The vertical coordinate of the left top corner of the key (pixels). */
posY: number;
};
export type MobileKeyboardZoneToKeyMapping = KeyBtn[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MobileKeyboardZoneToKeyMapping 这个名字似乎已经不合适了

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MobileKeyboardZoneToKeyMapping 这个名字似乎已经不合适了

明白,那我用MobileKeyboardBtns?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以的

/** The horizontal coordinate of the left top corner of the key (pixels). */
posX: number;
/** The vertical coordinate of the left top corner of the key (pixels). */
posY: number;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还缺了说明“这个 btn 绑定的是哪个 key”的字段?

*
* ## Props:
* - `ZoneToKeyMapping`: keyboard zone to key mapping configuration
* - `systemKeyConfig`: Optional array to customize system keys.If omitted, no system keys will be rendered.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个字段干掉了的话,这里的注释说明也干掉?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个字段干掉了的话,这里的注释说明也干掉?
嗯嗯,看漏了

/** The text displayed on the key. */
label: string;
/** The horizontal coordinate of the left top corner of the key (pixels). */
posX: number;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外还有 #2133 (comment) 这个问题需要考虑下

@qiniu-ci
Copy link

This PR has been deployed to the preview environment. You can explore it using the preview URL.

Warning

Please note that deployments in the preview environment are temporary and will be automatically cleaned up after a certain period. Make sure to explore it before it is removed. For any questions, contact the XBuilder team.

@nighca
Copy link
Collaborator

nighca commented Oct 10, 2025

@hwcctn 这个 PR 是不是可以 close 了?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants