Skip to content

Creating a component

Garuya edited this page Apr 21, 2017 · 3 revisions

https://github.com/ncsoft/Unreal.js/issues/111

let Compile = function(x) {  
    return require('uclass')()(global, x);
}

class CustomComponent extends MeshComponent {
    ctor() { }

    properties() {
        this.X /*EditAnywhere+int*/;
    }
}

let CustomComponentClass = Compile(CustomComponent)

class CustomActor extends Actor {
    ctor() {
        console.log("CustomActor ctor")

        this.Root = SceneComponent.CreateDefaultSubobject("ActorRootComponent")
        this.SetRootComponent(this.Root)

        this.CustomComponent = CustomComponentClass.CreateDefaultSubobject("CustomComponent")
        this.CustomComponent.AttachTo(this.Root)
    }

    properties() {
        this.Root /*VisibleAnywhere+BlueprintReadOnly+SceneComponent*/;
        this.CustomComponent /*VisibleAnywhere+BlueprintReadOnly+MeshComponent*/;
    }
}
Clone this wiki locally