Update README.md
This commit is contained in:
parent
7ad977ffca
commit
efec73f052
14
README.md
14
README.md
@ -380,6 +380,10 @@ public class SampleScript : MonoBehaviour
|
|||||||
{
|
{
|
||||||
var item = GameObject.Instantiate(prefab);
|
var item = GameObject.Instantiate(prefab);
|
||||||
item.GetComponentInChildren<Text>().text = x.ToString();
|
item.GetComponentInChildren<Text>().text = x.ToString();
|
||||||
|
|
||||||
|
// add to root
|
||||||
|
item.transform.SetParent(root.transform);
|
||||||
|
|
||||||
return item.gameObject;
|
return item.gameObject;
|
||||||
});
|
});
|
||||||
view.ViewChanged += View_ViewChanged;
|
view.ViewChanged += View_ViewChanged;
|
||||||
@ -387,14 +391,14 @@ public class SampleScript : MonoBehaviour
|
|||||||
|
|
||||||
void View_ViewChanged(in SynchronizedViewChangedEventArgs<int, string> eventArgs)
|
void View_ViewChanged(in SynchronizedViewChangedEventArgs<int, string> eventArgs)
|
||||||
{
|
{
|
||||||
if (eventArgs.Action == NotifyCollectionChangedAction.Add)
|
// hook remove event
|
||||||
{
|
if (NotifyCollectionChangedAction.Remove)
|
||||||
eventArgs.NewItem.View.transform.SetParent(root.transform);
|
|
||||||
}
|
|
||||||
else if (NotifyCollectionChangedAction.Remove)
|
|
||||||
{
|
{
|
||||||
GameObject.Destroy(eventArgs.OldItem.View);
|
GameObject.Destroy(eventArgs.OldItem.View);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// hook for Filter attached, clear, etc...
|
||||||
|
// if (NotifyCollectionChangedAction.Reset) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDestroy()
|
void OnDestroy()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user