[Editor Extension] Dynamicly adding Custom Node to Scene. Unknown Type Error!?!

[Editor Extension] Dynamicly adding Custom Node to Scene. Unknown Type Error!?!
0.0 0

#1

Hi,

how can I dynamicly add a custom to the Cocos Creator Editor Scene

I have a custom class:

class MyCustomNode extends cc.Node 
{
    constructor()
    {
        super();

        this.name = "MyCustomNode";
        this.setContentSize( cc.size(128, 128) );
        // this.properties.type = cc.Node;
    }
} 

When I add MyCustomNode dynamicly to Scene there is a Error in the Console “Unknown Type”.
So what can I do to solve this issue?

Second Question: How can I add own Properties to MyCustomNode, so that these Properties will show in Editor.

I would be glad if I get some Help from you guys…


#2

@zhangxm I just saw that you are developing Cocos Creator Extensions. Do you maybe have an answer to my question above? I just need a custom Node (a cc.Node extended with some extra properties) to add dynamicly to scene.

My scene-script should just add a custom Node like:

let _canvas = cc.find ('Canvas');
...
let _customNode = new MyCustomNode();
_canvas.addChild(customNode, 1);
...

#3

@MuratAlbayrak i don’t extend it, i just parse .fire and use the API provided by creator.


#4

@zhangxm Hmm, i see. Is there someone who I can ask? Maybe someone of the Cocos Creator Team who is also member of this Forum? I just want to know if this is a possible Task with Cocos Creator. I don’t want to give up this project yet. Sadly the Cocos Creator Documentation is to meager! Also most of the Content is in chinese Language. :-/


#5

@jare @pandamicro could you please take a look?


#6

Sorry you should not inherit cc.Node, the engine and editor not support custom node.


#7

okay, thank you for answering!


#8

Am I to understand that in Cocos Creator 1.5.2 it is not possible to add my own nodes to the “Custom Nodes” tab in the editor?

This tab is just here to tease me with future functionality?