我正在尝试使用以下Haxe Unreal插件。 https://github.com/proletariatgames/unreal.hx
我的类似乎没有错误编译但是当我尝试使用FObjectInitializer创建一个UStaticMeshComponent时,我在控制台中跟踪时会看到一个空值。
以下是我在调用CreateDefaultSubobject时用作参考的Haxe Extern
package unreal;
@:glueCppIncludes("UObject/UObjectGlobals.h")
@:noCopy @:noEquals @:uextern extern class FObjectInitializer {
public static function Get() : PRef<FObjectInitializer>;
@:thisConst
@:noTemplate
public function CreateDefaultSubobject<T : UObject>(Outer:UObject, SubojectName:FName, ReturnType:UClass, @:opt(ReturnType) ?ClassToCreateByDefault:UClass, bIsRequired:Bool=true, bAbstract:Bool=false, bIsTransient:Bool=false):T;
@:thisConst
@:uname("CreateDefaultSubobject")
@:typeName public function CreateDefaultSubobject_Template<T>(Outer:UObject, SubojectName:FName, bTransient:Bool=false) : PPtr<T>;
@:thisConst
@:typeName public function SetDefaultSubobjectClass<T>(SubojectName:FName) : Const<PRef<FObjectInitializer>>;
}
这是我的Haxe Unreal代码。
package fpsgame;
import unreal.*;
@:uclass
@:uname("AFPSObjectiveActor")
class FPSObjectiveActor extends AActor {
@:uproperty(VisibleDefaultsOnly, BlueprintReadOnly, Category=Mesh, meta=[AllowPrivateAccess="true"])
var MeshComp:UStaticMeshComponent;
var SphereComp:USphereComponent;
public function new(wrapper) {
super(wrapper);
var init = unreal.FObjectInitializer.Get();
MeshComp = init.CreateDefaultSubobject(new TypeParam<UStaticMeshComponent>(), this, new FName("MeshComp"), new TypeParam<UStaticMeshComponent>(), false);
RootComponent = MeshComp;
trace(RootComponent);
// SphereComp = init.CreateDefaultSubobject(new TypeParam<USphereComponent>(), this, new FName("SphereComp"), new TypeParam<USphereComponent>(), false);
// SphereComp.SetupAttachment(MeshComp);
}
}