Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Best practices for syncing lists of gameobjects to lists in UI?

Discussion in 'UGUI & TextMesh Pro' started by sdebaun, Sep 30, 2015.

  1. sdebaun

    sdebaun

    Joined:
    Jul 18, 2013
    Posts:
    4
    Hello! Unity 5 newbie, experienced programmer, looking for the right way to handle what must be a common use case:

    I want to show in my UI a list of networked gameobjects. Those gameobjects are all instances of a specific prefab. What's the cleanest way to keep my UI list synced to the set of gameobjects as they are spawned and destroyed? I'm specifically looking for ease of maintenance and code reuse.
     
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,688
  3. sdebaun

    sdebaun

    Joined:
    Jul 18, 2013
    Posts:
    4
    Wow, great link, thank you @SimonDarksideJ !

    Ive been working in angularjs for the past couple years and was bemoaning my lack of $scope.rows = Rows() :)

    MVVM doesnt look quite as easy to hookup but it seems like the right way to do it.
     
  4. nventimiglia

    nventimiglia

    Joined:
    Sep 20, 2011
    Posts:
    153
    @sdebaun I have an ListBinder for binding 'layout collections'. You can define you datamodel in plain C#, and then the control will automatically instantiate and bind your uGUI prefab to it. If you need any help, just post an issue to my github repo.

    https://github.com/NVentimiglia/Unity3d-Foundation