Esempio n. 1
0
    public void ShowAllLocation()
    {
        List <Location> resultLocations = new List <Location>(locations);

        emptyLocation.SetActive(false);

        for (int i = 0; i < locationButtons.Count; i++)
        {
            Destroy(locationButtons[i]);
        }
        locationButtons.Clear();

        for (int i = 0; i < locationProvinces.Count; i++)
        {
            GameObject     newLocationButton    = Instantiate(locationButton, contentParent);
            LocationButton locationButtonScript = newLocationButton.GetComponent <LocationButton>();
            locationButtonScript.SetLocation(locationProvinces[i]);
            locationButtons.Add(newLocationButton);
        }
    }
Esempio n. 2
0
    public void SearchLocation()
    {
        string keyword = searchTextField.text.Trim();
        List <LocationProvince> resultLocations = new List <LocationProvince>();

        if (keyword != "")
        {
            for (int i = 0; i < locationProvinces.Count; i++)
            {
                if (locationProvinces[i].location.placeNameThai.Contains(keyword) || locationProvinces[i].location.placeNameEng.Contains(keyword) || locationProvinces[i].provinceNameThai.Contains(keyword) || locationProvinces[i].provinceNameEng.Contains(keyword))
                {
                    resultLocations.Add(locationProvinces[i]);
                }
            }
        }

        for (int i = 0; i < locationButtons.Count; i++)
        {
            Destroy(locationButtons[i]);
        }

        if (resultLocations.Count > 0)
        {
            emptyLocation.SetActive(false);
            for (int i = 0; i < resultLocations.Count; i++)
            {
                GameObject     newLocationButton    = Instantiate(locationButton, contentParent);
                LocationButton locationButtonScript = newLocationButton.GetComponent <LocationButton>();
                locationButtonScript.SetLocation(resultLocations[i]);
                locationButtons.Add(newLocationButton);
            }
        }
        else
        {
            emptyLocation.SetActive(true);
        }
    }