ncsoft / Unreal.js

Unreal.js: Javascript runtime built for UnrealEngine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bp How to call unreal.js or override bp

ladyishenlong opened this issue · comments

https://github.com/ncsoft/Unreal.js/wiki/Override-Blueprint-Function
This document needs to create a new actor,so How to override an existing actor
Or is there any way to call unreal.js function from blueprint

Well, you are defining the behavior of an Actor in potentially three layers. C++, Blueprint, and JS.

And, for example, C++ doesn't know anything about what is defined only at the level of Blueprint, but you can define placeholder functions in C++ and override them in Blueprint. So C++ can call Blueprint functionality that way.

Similarly, Blueprint doesn't know anything about what is defined only at the level of JS, but you can define placeholder functions in Blueprint and override them in JS. So Blueprint can call JS functionality that way.

So create a Blueprint, with an empty function. Extend the generated class of the Blueprint with a JS class using the syntax in the link you found. Override the function in the JS class with whatever functionality you want. Convert the JS class into an Unreal class/blueprint/actor with the require('uclass') syntax shown in the link you found. Create a new instance of this new Actor using the 'new' keyword syntax shown in the link you found. Now that your actor is in the game world if any other actor (defined via C++, Blueprint, or JS) interacts with it and calls that function name, it will execute the JS functionality you defined.

好吧,您正在潜在的三层中定义 Actor 的行为。C++、蓝图和 JS。

例如,C++ 对仅在蓝图级别定义的内容一无所知,但您可以在 C++ 中定义占位符函数并在蓝图中覆盖它们。所以 C++ 可以通过这种方式调用蓝图功能。

同样,Blueprint 不知道仅在 JS 级别定义的内容,但您可以在 Blueprint 中定义占位符函数并在 JS 中覆盖它们。所以 Blueprint 可以通过这种方式调用 JS 功能。

因此,创建一个带有空函数的蓝图。使用您找到的链接中的语法,使用 JS 类扩展生成的蓝图类。用你想要的任何功能覆盖 JS 类中的函数。使用您找到的链接中显示的 require('uclass') 语法将 JS 类转换为 Unreal 类/蓝图/actor。使用您找到的链接中显示的“new”关键字语法创建此新 Actor 的新实例。现在,如果任何其他 Actor(通过 C++、Blueprint 或 JS 定义)与其交互并调用该函数名称,您的 Actor 就在游戏世界中,它将执行您定义的 JS 功能。

this is a good idea,Thank you for your reply