How to make an extension add a custom component?

39 Views Asked by At

I have a TypeScript file with a class that inherits cc.Component. I want to put it inside an extension package and have it accessible in the editor (have an option to add it to a node etc.) once the package is added. How can I accomplish that?

1

There are 1 best solutions below

0
On

Add the following code to the package.json:

"runtime-resource": {
    "path": "scripts",
    "name": "scripts"
}

Afterwards put your .ts file inside scripts folder in the package directory. Things should more or less look something like this as the result:

enter image description here

Source: https://discuss.cocos2d-x.org/t/how-to-make-an-extension-add-a-custom-component/51004/6?u=quickz