☑ How to send the variable from HTML to PlayCanvas

Hi.
The Fire from HTML does not reach to the JS of PlayCanvas.

https://playcanvas.com/project/419221/overview/test_comwithweb_sc2
Tested project is above.

The Fire from the other entity in PlayCanvas works fine.

http://developer.playcanvas.com/en/user-manual/publishing/web/communicating-webpage/
I was referring to the above-mentioned.

HTML code is the following:

<html>
<head>
    <meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no' />
    <meta charset='utf-8'>
    <link rel="stylesheet" type="text/css" href="styles.css">
    <link rel="manifest" href="manifest.json">
    <style></style>
    <title>test_ComWithWeb_sc2</title>
    <script src="playcanvas-stable.min.js"></script>
    <script>
        ASSET_PREFIX = "";
        SCRIPT_PREFIX = "";
        SCENE_PATH = "454899.json";
        CONTEXT_OPTIONS = {
            'alpha': false,
            'preserveDrawingBuffer': false
        };
        SCRIPTS = [ 4922381, 4922444 ];
        CONFIG_FILENAME = "config.json";
        pc.script.legacy = false;
    </script>
</head>
<body>
    <script src="__start__.js"></script>
    <script src="__loading__.js"></script>

	<script type="text/javascript">
	    var app = pc.Application.getApplication();
		console.log('sendParams');
		app.fire("setParams", "TEXT is SENT from HTML.");
    </script>

</body>
</html>

What is the problem?

Thanks.

Most likely the script assets have not been loaded yet. Try changing your code to

var app = pc.Application.getApplication();
app.on(‘initialize’, function () {
app.fire(‘setParams’, …);
});

The initial order of events that are fired when the app is starting is: start, initialize, postInitialize.

Thank you, vaios.

It works fine!

I remember it.

Thanks a lot.