Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by scaper_simblocks · Apr 20, 2018 at 05:57 PM · uiinputfieldselectable

Adding variables to Input Field and selecting an Input Field

Hello, I'm very new to Unity so I'm looking for some advice on how to do something properly. I've been asked to make a search box that will hold information from a search in different entries and allow the user to select an entry to get some feedback from the program. I've already created the search functionality by placing search results into a scroll view and it works great!

When I read an entry from the search results, I instantiate an input field and set its parent to be the content box in the scroll view. I also change the text to reflect the name of the search result. What I also need to have happen is that it holds on to an additional bit of info that has multiple fields, and I need to be able to detect when the user clicks on the entry so it can send that info to another part of the program. I'm not sure how to do either of these things properly, since the info is not a struct and I've yet to find a description on how to make an input box give a reaction by simply clicking on it.

What's the best way to accomplish this?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by oStaiko · Apr 21, 2018 at 12:11 AM

You can add a Button UI element to anything. You just need to set the TargetGraphic field of it to what you want to act as a button. I usually make Text elements buttons, but for an input field, you might want to make a regular button as a child of it it, delete the text, and make the color to transparent (set alpha to zero). just two ways to solve that problem.


For the other part with multiple fields, I don't really understand what you mean, but here's a guess. You can make a UI panel appear and disapear when you hover over the component, and include the additional info you want as a Text component in that panel. To do this, you need to add a component to your input called "Event Trigger", and add two new events to it, "PointerEnter" and "PointerExt", they should be at the top. It works the same as a button, and you need to drag a function from a script that just activates and deactivates the panel.


 public GameObject panel;
 
 public void Hover (bool boo)
 {
     panel.SetActive(boo);
 }

As a side note, I'm not sure why you are Instantiating an Input field to display results... Unless you want the user to be able to interact with it, use the Text component instead.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

133 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

NullReferenceException after passing InputField gameObject into EventSystem.SetSelectedGameObject() 1 Answer

Automatic navigation does not work with Inherited InputField 1 Answer

Input Field caret position is wrong when I type Chineese using Win10 System IME. 1 Answer

Making a UI.Button put text into a InputField 1 Answer

InputField limits characters unwantedly, even with no character limit 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges