Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Working with float arrays and grid display

Discussion in 'UI Toolkit' started by Destruxion, Dec 15, 2022.

  1. Destruxion

    Destruxion

    Joined:
    Jun 5, 2019
    Posts:
    22
    Hey,

    I am looking for the best way to create a visual element setup (editor) that binds to a simple float array property and can display it in a 2d float value grid.

    Like a float[25] array of fixed length being displayed in a 5x5 grid for editing.

    I looked through the documentation and could not find a component that can handle this out of the box.

    Any tips how to get started?
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,844
    UI Toolkit doesn't have out of the box grid-view support, but it's pretty straight forward to implement it yourself using visual elements as rows, and filling them up with more visual elements as columns.
     
  3. Destruxion

    Destruxion

    Joined:
    Jun 5, 2019
    Posts:
    22
    Thanks. Buidling custom elements is in fact a lot easier than I expected. I was a little worried about the binding part when using a float array, but after we started replacing the current BindProperty workflow with a custom solution things are a lot easier and in our case (node graph) more manageable.