Announcement
Collapse
No announcement yet.
Call C++ functions from JS
Collapse
X
-
Nybörjaren123 repliedSo i wasted 2-3 days in about the same process as you have Aros_Prince. The problem is i don't understand your last comment. Care to make a short step by step tutorial for the rest of us to understand how the new UE integration (which i can't find any information on anywhere btw) works?.
-
Aros_Prince repliedTo conclude this... This whole idea was based on an old UE integration. Nowadays, you don't need to mess with any of the stuff above.
Files to look at:- Engine/Source/Runtime/HTML5/HTML5JS/Private/HTML5JavaScriptFx.js
- Engine/Source/Runtime/HTML5/HTML5JS/Public/HTML5JavaScriptFx.h
As for the HTML5 macro, nowadays, it's just: PLATFORM_HTML5
Leave a comment:
-
ArosPrince repliedI tried to edit:
Code:\Engine\Source\Programs\UnrealBuildTool\Platform\HTML5\HTML5ToolChain.cs
Code:Result += " -s EXTRA_EXPORTED_RUNTIME_METHODS=\"['Pointer_stringify', 'writeAsciiToMemory', 'stackTrace', 'ccall']\"";
Leave a comment:
-
ArosPrince repliedOK, at this point, I was able to solve it by putting this in the cpp file:
Code:#ifdef __EMSCRIPTEN__ #include <emscripten.h> #include <emscripten/html5.h> #define PLATFORM_HTML5_BROWSER 1 #endif
The next question however would be... I get this in the console when I run the app:
Code:'ccall' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)
Thanks
Leave a comment:
-
ArosPrince started a topic Call C++ functions from JSCall C++ functions from JS
Hi,
I need to be able to call C++ (or blueprint) functions from JavaScript. I know that Unreal uses Emscripten to pack the C++ code to HTML5 build. It should be integrated in Unreal, but it is still not clear to me how to actually use it. I am able to build my Blueprint / C++ app in HTML5 and run it, but I just don't understand how to call the C++ functions. According to this thread, it should be possible:
https://answers.unrealengine.com/que...avascript.html
But what I don't get is:
- PLATFORM_HTML5_BROWSER is not defined at all. No matter if I run from editor or package the APP as HTML5, it is not defined. Am I supposed to do it myself? Because I would expect it to behave similarly as for example PLATFORM_WINDOWS...
- those EMSCRIPTEN_KEEPALIVE and other EMSCRIPTEN macros are not defined. Am I suppose to include anything? I tried to include <emscripten.h>, but that fails right away when trying to build the editor so I cannot even get to packaging the app for HTML5.
The best thing would be if there was some comprehensive tutorial for JS / C++ integration, but that doesn't seem to be the case. Or is it?
Thanks!
Leave a comment: