ncsoft / Unreal.js

Unreal.js: Javascript runtime built for UnrealEngine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example code for how to connect C++ to JS

jeebs00 opened this issue · comments

Is there an example or documentation that explains how to expose C++ class functions for the plugin to pickup in a JS file? I am wanting to define a C++ class that I can call functions on in JS, I currently have them defined as UFUNCTIONS(BlueprintCallable) in a UCLASS() that extends AActor, but they are not being exposed in ue.d.ts file and I can't find where/what will trigger that file to update.

Mostly looking for an example of how to connect a C++ to be able to call a JS file, preferably without a function main(), to run a defined function (so how do I setup and instantiate a FJavascriptFunction in C++), since I could use the execute to pass the wanted parameters.

You can use expose function on a UObject* and it will have its functions callable from Js. See https://github.com/ncsoft/Unreal.js-core/blob/00305fc2b958f7819b66f7e23178c61ab54dbb84/Source/V8/Public/JavascriptComponent.h#L87

Also in my experience any c++ class with public api in module once compiled is subclassable and callable from Js, but I might be mistaken.

When exposed that way it becomes referenceable. Even with the class exposed as API and UClass defined with UFUNCTIONS and UPROPERTY it wasn't updating.