Why reparent doesnt work?

Hi! I want to implemet scroll view as in your example
But when I try to reparent created instance its shows an error that says Uncaught TypeError: parent.addChild is not a function

Here is my code

DebugPanel.prototype.initialize = function(){
    _pingPanel = this.ping.element;
    _content = this.scrollView.scrollview.contentEntity;

DebugPanel.prototype.addUser = function(playerData){

    this.usersAmount.element.text = 'Users amount: ' + _playersAmount.toString();

    var instance = this.userTemplate.resource.instantiate();
    instance.element.text = playerData.id;

    instance.on('destroy', function() {
    }, this);


What am I doing wrong?

Hi @Oleksii_Dubrovskyi,

You can call reparent() only on an already parented entity.

Since here you are creating a new entity, call addChild() directly:


I saw this part of code in your example. I think that bug doesnt fixed yet. When i added it to my solution it works perfect. Thanks!

    // There's a bug with this property so this is a tempoary workaround until it is fixed
    if (typeof(this._content) === 'string') {
        this._content = this.app.getEntityFromIndex(this._content);
1 Like

The issue here is potentially scope or that this.scrollView.scrollview.contentEntity is not an Entity (ie null) or some init call order related issue.

There are a lot of global variables being used here which is probably not helping.

Can you share a project that shows the issue the please?

Ah yes, there is a bug where the entity is a guid rather than a pc.Entity :frowning: