ncsoft / Unreal.js

Unreal.js: Javascript runtime built for UnrealEngine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

After packing, Blueprint.Load is invalid

ladyishenlong opened this issue · comments

class WebInfoActor extends Blueprint.Load("/Game/Szls/web/BP_WebInfo").GeneratedClass{
    setWebInfo(type,json,funcName){
        PrintUtil.PrintString(type)
        //todo 
        switch (type){
            case "":
                break;
        }
    }
}

let WebInfoActor_1 = uclass(WebInfoActor)
new WebInfoActor_1(GWorld,{Z:0})

It can be printed normally in the editor
But it doesn't work after packing

I referenced
https://github.com/ncsoft/Unreal.js/wiki/Cooking
doesn't work

A simple packaged build on Windows is working for me.
image
Note the settings for Class Assets in the details panel there. Then in game.js I have:

/// <reference path="typings/ue.d.ts">/>

Context.RunFile("aliases.js");
Context.RunFile("polyfill/unrealengine.js");
Context.RunFile("polyfill/timers.js");

class MyBlueprintJS extends Root.ResolveClass('MyBlueprint') {}
const MyBlueprintUC = require('uclass')()(global, MyBlueprintJS);
const instance = new MyBlueprintUC(GWorld);
instance.SetActorLocation({ X: 1000, Y: 2000, Z: 500 });
instance.SetText("Hello");

const instance2 = GWorld.GetActorOfClass(MyBlueprintUC);
instance2.SetText("Hello again!");

Then I build a packaged build for Windows. It completes successfully. Then I manually copy Project/Plugins/UnrealJS/Content to Build/Windows/Project/Content. Then I manually copy Project/Content/Scripts to `Build/Windows/Project/Content/Scripts``. It works in the editor without the Context.RunFile(...) calls. But it does need them in the packaged build. I think I saw that in one of the sample files. Here is a screenshot from the running packaged build.
image

Windows 上的简单打包构建对我有用。 请注意那里的详细信息面板中的类资产设置。然后在game.js中我有: 图片

/// <reference path="typings/ue.d.ts">/>

Context.RunFile("aliases.js");
Context.RunFile("polyfill/unrealengine.js");
Context.RunFile("polyfill/timers.js");

class MyBlueprintJS extends Root.ResolveClass('MyBlueprint') {}
const MyBlueprintUC = require('uclass')()(global, MyBlueprintJS);
const instance = new MyBlueprintUC(GWorld);
instance.SetActorLocation({ X: 1000, Y: 2000, Z: 500 });
instance.SetText("Hello");

const instance2 = GWorld.GetActorOfClass(MyBlueprintUC);
instance2.SetText("Hello again!");

然后我为 Windows 构建了一个打包版本。它成功完成。然后我手动复制Project/Plugins/UnrealJS/ContentBuild/Windows/Project/Content. 然后我手动复制Project/Content/ScriptsBuild/Windows/Project/Content/Scripts。它在没有 Context.RunFile(...) 调用的编辑器中工作。但它确实需要它们在打包的版本中。我想我在其中一个示例文件中看到了这一点。这是正在运行的打包构建的屏幕截图。 图片

Thank you for your help
your approach worked
However, my method of rewriting the blueprint is still invalid after packaging, but it works in the editor

Context.RunFile("aliases.js");
Context.RunFile("polyfill/unrealengine.js");
Context.RunFile("polyfill/timers.js");

const PrintUtil=require("./util/PrintUtil")
PrintUtil.PrintString("游戏开始")

class WebInfo extends Root.ResolveClass('BP_WebInfo') {
    setWebInfo(type,json,funcName){
        PrintUtil.PrintString(json)
        switch (type){
            case "":
                break;
        }
    }
}

const MyBlueprintUC = require('uclass')()(global, WebInfo);
const instance = new MyBlueprintUC(GWorld);
instance.SetActorLocation({ X: 0, Y: 0, Z: 100 });

T0%KB 4)GVN)@AG3MW8~GRS

I mean the actor is created, but the blueprint override doesn't work

I tested again and found that js has covered the method in the blueprint, the blueprint method is not executed, and the method in js is not executed at the same time

Hmm. Your example is working for me, if I understand correctly. You are asking about overriding an event defined in Blueprint (not a function) in JS?

In MyBlueprint I have a function SetText and an event SetText2. The functionality for SetText is defined in Blueprint. The functionality for SetText2 is defined in JS. The JS functionality calls the Blueprint functionality. It still works fine in the editor and in the packaged build for me.

image

image

Context.RunFile("aliases.js");
Context.RunFile("polyfill/unrealengine.js");
Context.RunFile("polyfill/timers.js");

class MyBlueprintJS extends Root.ResolveClass('MyBlueprint') {
  SetText2(text) {
    this.SetText(text);
  }
}
const MyBlueprintUC = require('uclass')()(global, MyBlueprintJS);
const instance = new MyBlueprintUC(GWorld);
instance.SetActorLocation({ X: 1000, Y: 2000, Z: 500 });

instance.SetText2("Fired event");

Hmm. Your example is working for me, if I understand correctly. You are asking about overriding an event defined in Blueprint (not a function) in JS?

In MyBlueprint I have a function SetText and an event SetText2. The functionality for SetText is defined in Blueprint. The functionality for SetText2 is defined in JS. The JS functionality calls the Blueprint functionality. It still works fine in the editor and in the packaged build for me.

image

image

Context.RunFile("aliases.js");
Context.RunFile("polyfill/unrealengine.js");
Context.RunFile("polyfill/timers.js");

class MyBlueprintJS extends Root.ResolveClass('MyBlueprint') {
  SetText2(text) {
    this.SetText(text);
  }
}
const MyBlueprintUC = require('uclass')()(global, MyBlueprintJS);
const instance = new MyBlueprintUC(GWorld);
instance.SetActorLocation({ X: 1000, Y: 2000, Z: 500 });

instance.SetText2("Fired event");

I know what's going on
Overridden blueprint methods cannot be called directly in other existing blueprints