# Function register

- register<T>(name: string, canNew?: boolean): ((ctor: any) => void)

- 注册组件到ecs系统中

  ### Example

      // 注册实体
      @ecs.register('Role')
      export class Role extends ecs.Entity {

      }

      // 注册数据组件
      @ecs.register('RoleModel')
      export class RoleModelComp extends ecs.Comp {
         id: number = -1;

         reset() {
             this.id =  -1;
         }
      }

      // 注册系统组件
      @ecs.register('Initialize')
      export class InitResSystem extends ecs.ComblockSystem implements ecs.IEntityEnterSystem {

      }

      // 注册显示对象组件
      @ccclass('RoleViewComp')
      @ecs.register('RoleView', false)
      export class RoleViewComp extends CCComp {
         onLoad(){

         }
      }

  #### Type Parameters

  - #### T

  #### Parameters

  - ##### name: string

    由于js打包会改变类名，所以这里必须手动传入组件的名称

  - ##### canNew: boolean = true

    标识是否可以new对象。想继承自Cocos Creator的组件就不能去new，需要写成@ecs.register('name', false)

  #### Returns ((ctor: any) => void)

  - - (ctor: any): void

    - #### Parameters

      - ##### ctor: any

      #### Returns void

  - Defined in assets/libs/ecs/ECS.ts:120

Generated using TypeDoc