Exemplo n.º 1
0
        protected override bool PopulateDropDown()
        {
            _availableStreetLights = PropCustomizer.Instance.GetAvailableStreetLights(SelectedPrefab);

            if (SelectedPrefab != null && _availableStreetLights != null && PropCustomizer.Instance.HasStreetLights(SelectedPrefab))
            {
                var defaultProp = PropCustomizer.Instance.GetDefaultStreetLight(SelectedPrefab);
                var activeProp  = PropCustomizer.Instance.GetActiveStreetLight(SelectedPrefab);

                DropDown.items = new string[0];

                foreach (var prop in _availableStreetLights)
                {
                    var itemName = UIUtil.GenerateBeautifiedPrefabName(prop);
                    itemName = BeautifyNameEvenMore(itemName);
                    if (prop == defaultProp)
                    {
                        itemName += " (Default)";
                    }

                    DropDown.AddItem(itemName);

                    if (prop == activeProp)
                    {
                        DropDown.selectedIndex = DropDown.items.Length - 1;
                    }
                }

                var defaultDistance = PropCustomizer.Instance.GetDefaultStreetLightDistance(SelectedPrefab);
                var activeDistance  = PropCustomizer.Instance.GetActiveStreetLightDistance(SelectedPrefab);
                TextField.text    = activeDistance.ToString(CultureInfo.InvariantCulture);
                TextField.tooltip = $"Distance between street lights in m (default {defaultDistance})\nValue must be between 1 and 100!";

                if (_availableStreetLights.Count >= 2)
                {
                    DropDown.Enable();
                }
                else
                {
                    DropDown.Disable();
                }
                return(true);
            }
            return(false);
        }