Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

How do we create a FloatInput (FloatField without label)?

Discussion in 'UIElements' started by Vapid-Linus, Aug 7, 2019.

  1. Vapid-Linus

    Vapid-Linus

    Joined:
    Aug 6, 2013
    Posts:
    58
    How do we create float field without a label?

    Looking at how FloatField does it, it uses a FloatInput:


    However, we do not have access to the FloatInput:

    Code (JavaScript):
    1. <FloatInput text="123" />
    My use case at the moment is creating a ranged slider, which looks like the one created by the Range attribute:


    You can see the little input field to the right of the slider. That's what I'm trying to create.

    The current Slider tag creates a slider without the input field:

    Code (JavaScript):
    1. <VisualElement class="row">
    2.     <Slider label="Speed Loss Per Level" binding-path="SpeedLossPerLevelFactor" class="grow" />
    3.     <FloatInput binding-path="SpeedLossPerLevelFactor" class="grow" />
    4.   </VisualElement>
    5.  
    So how do we create a float input field without a label? Why is the FloatInput class an internal class for FloatField?

    Edit:
    My temporary "solution" to the slider problem is to just display a label after it. Doesn't look as good as the intended input field and it's not editable, so it's not a perfect solution but works for me. I also round mine to one decimal, but here's my solution in case it's useful for someone:

    template
    style
    custom editor
     
    Last edited: Aug 7, 2019
  2. jonathanma_unity

    jonathanma_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    35
    Hi,

    You can try to create a FloatField without a label, this should give you the FloatInput as desired.