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

Linking data to UI elements

Discussion in 'UGUI & TextMesh Pro' started by vee41, Apr 6, 2016.

  1. vee41

    vee41

    Joined:
    Nov 14, 2013
    Posts:
    32
    Hi!

    What are some methods for keeping your UI information updated?

    The obvious way is to hardcode every ui piece to fetch and display the proper information. Then there is more MVVM etc. style approach that assets like Data Binding provide. This seems a bit excessive in many cases as there is layer of abstraction that I dont have much use for.

    What I'd love is a way to say for my text element "this is the piece of information you display", preferably via nice inspector setup. Are there simpler approaches to this than the MVVM approach?
     
  2. SlyRipper

    SlyRipper

    Joined:
    Jun 19, 2012
    Posts:
    251
    How about using a simple event system? just trigger an event when your value changes and the UI element watches that event, so whenever it triggers, it updates its value. So you don't have to watch constantly, if the value has changed, as the event only triggers only when the value actually changes.