Skip to content

BindChildPrefabsTo() destroys transform instead of gameobject #3

Open

Description

@Last8Exile

GameObjectExtensions.BindChildPrefabsTo() should destroy instantiated prefabs during element removal from ReactiveCollection.
But GameObjectExtensions.onElementRemoved() destorys transform of instantiated prefab instead of gameobject.
This is not working if instance has RectTransfom.
There are 2 cases:

  1. RectTransfom destoryed and replaced with Transform.
  2. RectTransform not destroyed because there is another component depending on it.

In both cases actual gameobject not destroyed.

I suggest replcaing impelmentation of GameObjectExtensions.onElementRemoved() to:

void onElementRemoved(CollectionRemoveEvent<T> data)
{
    var existingChild = input.transform.GetChild(data.Index).gameObject;
    onChildRemoving?.Invoke(data.Value, existingChild);
    GameObject.Destroy(existingChild);
}

Activity

  1. grofit commented on Jan 24, 2023

    @grofit
    Owner

    Oh right, by all means push a PR through for that then as you say it should be destroying the GO not just the Transform component, I assumed it would delete the whole GO with the existing code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions