Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
neuecc authored Sep 6, 2024
1 parent 7ad977f commit efec73f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,21 +380,25 @@ public class SampleScript : MonoBehaviour
{
var item = GameObject.Instantiate(prefab);
item.GetComponentInChildren<Text>().text = x.ToString();

// add to root
item.transform.SetParent(root.transform);

return item.gameObject;
});
view.ViewChanged += View_ViewChanged;
}

void View_ViewChanged(in SynchronizedViewChangedEventArgs<int, string> eventArgs)
{
if (eventArgs.Action == NotifyCollectionChangedAction.Add)
{
eventArgs.NewItem.View.transform.SetParent(root.transform);
}
else if (NotifyCollectionChangedAction.Remove)
{
// hook remove event
if (NotifyCollectionChangedAction.Remove)
{
GameObject.Destroy(eventArgs.OldItem.View);
}

// hook for Filter attached, clear, etc...
// if (NotifyCollectionChangedAction.Reset) { }
}

void OnDestroy()
Expand Down

0 comments on commit efec73f

Please sign in to comment.