예제 #1
0
    void Sync()
    {
        var provinces = PlaceUtility.GetProvinces();

        foreach (var province in provinces)
        {
            var citys = PlaceUtility.GetCitys(province);
            foreach (var city in citys)
            {
                var directs = PlaceUtility.GetDistricts(province, city);
                foreach (var direct in directs)
                {
                    Debug.Log(string.Format("{0}/{1}/{2}", province.Name, city.Name, direct.Name));
                }
            }
        }
    }
예제 #2
0
    private void BindDistrict()
    {
        if (provinces == null || provinces.Length == 0)
        {
            return;
        }
        if (citys == null || citys.Length == 0)
        {
            return;
        }

        PlaceModel province = provinces[comboBoxProvince.value];
        PlaceModel city     = citys[comboBoxCity.value];

        if (province != null && city != null)
        {
            districts = PlaceUtility.GetDistricts(province, city);
            this.InvokeToForm(() =>
            {
                var list = new List <Dropdown.OptionData>();
                comboBoxDistrict.ClearOptions();
                foreach (var item in districts)
                {
                    var option  = new Dropdown.OptionData();
                    option.text = item.Name;
                    list.Add(option);
                }
                comboBoxDistrict.AddOptions(list);
                if (comboBoxDistrict.value != 0)
                {
                    comboBoxDistrict.value = 0;
                }
                else
                {
                    ComboBoxDistrict_SelectedIndexChanged(0);
                }
            });
        }
        else
        {
            this.InvokeToForm(() => lblStatus.text = "地区加载错误,请确保联网正确");
        }
    }