Skip to content

feat(2d): support pixelsToUnit in SpriteFrame.reset - #203

Open
shrinktofit wants to merge 1 commit into
cocos:v4.0.0from
shrinktofit:codex/sprite-frame-reset-pixels-to-unit
Open

feat(2d): support pixelsToUnit in SpriteFrame.reset#203
shrinktofit wants to merge 1 commit into
cocos:v4.0.0from
shrinktofit:codex/sprite-frame-reset-pixels-to-unit

Conversation

@shrinktofit

Copy link
Copy Markdown
Contributor

Re: #

This gives callers an opportunity to set pixels per unit when initializing a SpriteFrame through reset(), for example when creating sprite frames directly in tests. Unity's Sprite.Create similarly accepts a pixelsPerUnit argument at sprite creation time.

Changelog

  • Support setting pixelsToUnit through SpriteFrame.reset().

Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

@shrinktofit

Copy link
Copy Markdown
Contributor Author

@cocos-robot run test cases

@github-actions

Copy link
Copy Markdown

Code Size Check Report

Wechat (WASM) Before After Diff
2D Empty (legacy pipeline) 1014446 bytes 1014590 bytes ⚠️ +144 bytes
2D All (legacy pipeline) 2681971 bytes 2682115 bytes ⚠️ +144 bytes
2D All (new pipeline) 2773763 bytes 2773907 bytes ⚠️ +144 bytes
(2D + 3D) All 10031072 bytes 10031216 bytes ⚠️ +144 bytes
Web (WASM + ASMJS) Before After Diff
(2D + 3D) All 16867485 bytes 16867629 bytes ⚠️ +144 bytes

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -732,8 +732,14 @@
          * 在图集中的精灵帧可能会被剔除透明像素以获得更高的空间利用李,剔除后的矩形尺寸比剪裁前更小,偏移量指的是从原始矩形的中心到剪裁后的矩形中心的距离。
          */
         offset?: math.Vec2;
         /**
+         * @en Number of pixels corresponding to unit size in world space.
+         * @zh 世界空间中的单位大小对应的像素数量。
+         * @default 100
+         */
+        pixelsToUnit?: number;
+        /**
          * @en Top side border for sliced 9 frame.
          * @zh 九宫格精灵帧的上边界。
          * @default 0
          */
@@ -1156,9 +1162,9 @@
          * @en clone a sprite frame.
          * @zh 克隆当前 sprite frame。
          */
         clone(): SpriteFrame;
-        protected _refreshTexture(texture: __private._cocos_asset_assets_texture_base__TextureBase): void;
+        protected _refreshTexture(texture: __private._cocos_asset_assets_texture_base__TextureBase, updateMesh?: boolean): void;
         /**
          * @en complete loading callback.
          * @zh 加载完成回调。
          * @deprecated since v3.7.0, this is an engine private interface that will be removed in the future.

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.

1 participant