Introduction to the Preview Process And Common Error Handling
Introduction to the Preview Process
When opening Cocos Creator, the editor will open a web server (we use Express). When clicking the preview button, the user's default browser will open and access the preview URL. The Editor uses preview templates to write some simple logic for loading the engine, initializing the game, loading game assets. The loading of game assets mainly depends on the generation of
setting.js records the url of assets, scripts, and some project settings. The
setting.js is generated by calling the interface of the build plugin. If
setting.js is not generated correctly, you can open the build debugging tool to inspect.
Common Error Handling
Ensure that all error are solved before previewing.
Loading setting.js Fails
You can open Developer -> Build Debugging Tools to see if there are any error messages.
Under normal circumstances, if generating
settings.js fails, there will be error messages in console. Most common is a script error, because when generating
settings.js, all scripts in the project are loaded in the build process. If any script contains illegal writing, an unexpected error will be thrown during the loading process and
setting.js will fail to be generated. For specific error message information, you can refer to the hint in the error message. Usually the error content here is the uuid of the asset. The corresponding
uuid can be copied to the Assets panel to search and locate the script.
Please refer to the Introduction To The Build Process documentation for additional details about how
settings.js is generated.
Assets Loading with a 404
Usually, this is caused by asset loss or import failure. Please use the missing asset uuid to search in the editor's assets panel. If no assets are found, usually the asset is lost. You need to modify the scene or asset using the assets. If assets are found, you can try to re-import.