Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show correct type for preloadScene #17625

Open
wants to merge 1 commit into
base: v3.8.5
Choose a base branch
from
Open

Conversation

MrcSnm
Copy link

@MrcSnm MrcSnm commented Sep 10, 2024

Re: #17624

Changelog

The old type was misleading
*


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.

Copy link

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -27159,9 +27159,9 @@
          * 就算预加载还没完成,你也可以直接调用 `director.loadScene`,加载完成后场景就会启动。
          * @param sceneName @en The name of the scene to load @zh 场景名称。
          * @param onLoaded @en Callback to execute once the scene is loaded @zh 加载回调。
          */
-        preloadScene(sceneName: string, onLoaded?: Director.OnSceneLoaded): void;
+        preloadScene(sceneName: string, onLoaded?: Director.OnScenePreloaded): void;
         /**
          * @en
          * Pre-loads the scene to reduces loading time. You can call this method at any time you want.<br>
          * After calling this method, you still need to launch the scene by `director.loadScene`.<br>
@@ -27173,9 +27173,9 @@
          * @param sceneName @en The name of scene to load @zh 场景名称。
          * @param onProgress @en Callback to execute when the load progression change.  @zh 加载进度回调。
          * @param onLoaded @en Callback to execute once the scene is loaded @zh 加载回调。
          */
-        preloadScene(sceneName: string, onProgress: Director.OnLoadSceneProgress, onLoaded: Director.OnSceneLoaded): void;
+        preloadScene(sceneName: string, onProgress: Director.OnLoadSceneProgress, onLoaded: Director.OnScenePreloaded): void;
         /**
          * @en Resume game logic execution after pause, if the current scene is not paused, nothing will happen.
          * @zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。
          */
@@ -27298,8 +27298,9 @@
     }
     export namespace Director {
         export type OnBeforeLoadScene = () => void;
         export type OnUnload = () => void;
+        export type OnScenePreloaded = (error?: Error) => void;
         export type OnSceneLoaded = (error: null | Error, sceneAsset?: SceneAsset) => void;
         export type OnSceneLaunched = (error: null | Error, scene?: Scene) => void;
         /**
          * @param completedCount - The number of the items that are already completed.

@@ -819,6 +819,7 @@ export declare namespace Director {

export type OnUnload = () => void;

export type OnScenePreloaded = (error?: Error) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, rename it to OnScenePreloaded is more clear. But it will break compatibility.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah the main problem is that the current interface is really misleading since the extra argument. I wanted instead to at least make it valid

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.

2 participants