Replies: 1 comment
-
拿到那个对象后,用as转成改类型,然后调用 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
我在A的ts类里加载了一个的B的ts类,当B类Actor被点击时触发A类的自定义方法。由于A是继承自 UE.Actor 的,如果不在ts声明就无法调用。
A类如下
class A extends UE.Actor {
CustomMethod(): void {
console.log('enter custom method');
}
ReceiveBeginPlay(): void {
const BpClass = UE.Class.Load("/Game/Blueprints/TypeScript/B.B_C");
(this.GetWorld()).SpawnActor(BpClass, undefined, UE.ESpawnActorCollisionHandlingMethod.Undefined, this, undefined);
}
}
B类如下
class B extends UE.Actor {
ReceiveActorOnClicked(ButtonPressed: UE.Key): void {
this.Owner.CustomMethod();
}
}
如果不在 ue.d.ts中给Actor类的声明加一个CustomMethod ,ts编译就无法通过,会报错 类型“Actor”上不存在属性“CustomMethod”。
如果手动在ue.d.ts中给Actor类的声明加一个CustomMethod,上述代码能正常运行。但这个方法肯定有问题,我不太清楚ts蓝图类之间如何调用自定义方法,一个ts蓝图类继承了UE类并且有一个自定义方法,怎么写才能正常通过ts编译呢?
Beta Was this translation helpful? Give feedback.
All reactions