- Home /
 
 
               Question by 
               Konrad1337 · Nov 10, 2020 at 01:44 PM · 
                buttoninputfieldsearch  
              
 
              Searching buttons with inputfield.
Hello. I am totally new in Unity and my english is not perfect. I want make search engine in my app. Every object is button.
I made inputfield and this code for "On Value Change(String)" event:
 List<GameObject> buttons = new List<GameObject>();
 public void SearchEngine()
         {
             search = inp.text;
             if (string.IsNullOrEmpty(search))
             {
                 foreach (GameObject b in buttons)
                 {
                     b.SetActive(true);
                 }
             }
             else
             {
                 foreach (GameObject b in buttons)
                 {
                     if (!b.GetComponent<ButtonScript>().txtNazwa.text.Contains(search))
                     {
                         b.SetActive(false);
                     }
                 }
             }
         }
 
               When there is a button with Text 'txtNazwa' and "abcdefgh" and i write "abc" it's good. Problem is when i write for example "abcz" and i remove 'z'. After remove mistake letter buttons can't be active again. I need to delete all text from inputfield and write again all.
               Comment
              
 
               
              Answer by Konrad1337 · Nov 10, 2020 at 01:51 PM
ok it's done. I just added
 else
                 {
                     b.SetActive(true);
                 }
 
              Your answer