c# – How can I access text from a TMPro input in Unity and link a dropdown to a text input field?

For some context, I am experimenting with a unit conversions app in Unity where the user inputs their number, selects a unit from a dropdown menu and the result is displayed in another (non-interactable) input field to a unit from another dropdown menu.

I am using an Input Field – Text Mesh Pro in my UI which has a content type of ‘Decimal Number’. How can I access this number in Unity as a float that I can perform mathematical calculations on?

I also want to link this to the aforementioned dropdowns using a CASEWHERE structure (in C#) but am unsure how to do so. E.g. if I am converting 120 degrees Farenheit to Celsius and then Celsius to Farenheit and then Celsius to Kelvin and so on… would I need to make a separate function for each calculation?


Source link

More To Explore

Share on facebook
Share on twitter
Share on linkedin
Share on email