Demo of registering custom URL protocol handler.
-
We register
my-packed-data:/protocol to read data from a ZIP file. The demo code shows 2 approaches to register the handler:-
When
USE_ZIP_URL_HANDLERsymbol is not defined: Use a generic way to register URL handler usingCastleDownload.RegisterUrlProtocol. -
When
USE_ZIP_URL_HANDLERsymbol is defined: UseTCastleZipandTCastleZip.RegisterUrlProtocolto register the handler. This is simpler and more efficient, but it serves a more specific use case: it allows to read contents from a ZIP file by accessingmy-packed-data:/...URLs.
-
-
Furthermore, we use
ApplicationDataOverrideto load game data from this protocol. This waycastle-data:/my_image.pngwill actually get data frommy-packed-data:/my_image.png.This is done in the same way, regardless of whether
USE_ZIP_URL_HANDLERsymbol was defined or not, so regardless of how themy-packed-data:/...protocol was registered.
In effect, we read game data from a ZIP file, but you use castle-data:/ as usual.
Migrate to use UI designed by CGE editor and use TCastleView.