- 
                Notifications
    You must be signed in to change notification settings 
- Fork 348
Creating a custom component
        arthursw edited this page May 4, 2016 
        ·
        1 revision
      
    function compile(x) {
  return require('uclass')()(global,x)
}
class MyComponent /*EditInlineNew*/ extends ActorComponent {
  ctor() {
    this.Param1 = 23
    this.Param2 = {X:1,Y:2,Z:3}
  }
  properties() {
    this.Param1/*EditAnywhere+BlueprintReadOnly+Category:Javascript+int*/;
    this.Param2/*EditAnywhere+Category:Javascript+Vector*/;
  }
}
let MyComponent_C = compile(MyComponent)
class MyActor extends Actor {
  // pre-ctor; you can switch subobject to another class defined in super class.
  prector() {
    MyMovementComponent_C.SetDefaultSubobjectClass("CharMoveComp")
  }
  ctor() {
    this.MyComponent = MyComponent_C.CreateDefaultSubobject("MyComponent")
  }
  
  properties() {
    this.MyComponent/*VisibleAnywhere+Category:Javascript+MyComponent*/;
  }
}
let MyActor_C = compile(MyActor)
let actor = Actor.C(new MyActor_C(GWorld))