puerts icon indicating copy to clipboard operation
puerts copied to clipboard

[Unreal 4.26]蓝图生成问题 似乎无法调用扩展函数

Open morirain opened this issue 5 years ago • 3 comments

ReceiveBeginPlay(): void {
    let world = this.GetWorld()
    let actor = world.SpawnActor(UE.MainActor.StaticClass(), undefined, UE.ESpawnActorCollisionHandlingMethod.Undefined, undefined, undefined) as UE.MainActor;
}
        let actor = world.SpawnActor(UE.MainActor.StaticClass(), undefined, UE.ESpawnActorCollisionHandlingMethod.Undefined, undefined, undefined);
                          ^
TypeError: world.SpawnActor is not a function

基于新Clone的Demo测试,也写过其他的扩展函数测试过,在QuickStart.ts的虚拟机中测试正常,蓝图生成则会出现错误。

morirain avatar Feb 06 '21 14:02 morirain

扩展函数要放到启动JSEnv所在模块,也就是puerts模块里,否则遍历不到

chexiongsheng avatar Feb 06 '21 14:02 chexiongsheng

懂了,所以其实不算bug,用文档说明会好一点。

morirain avatar Feb 06 '21 14:02 morirain

所以请问这个该怎么写?

ladyishenlong avatar Oct 09 '22 05:10 ladyishenlong