Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BindChildPrefabsTo() destroys transform instead of gameobject #3

Open
Last8Exile opened this issue Jan 24, 2023 · 1 comment
Open

Comments

@Last8Exile
Copy link

Last8Exile commented Jan 24, 2023

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);
}
@grofit
Copy link
Owner

grofit commented Jan 24, 2023

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants