//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void BuildItem() { switch ( Type ) { case HoverboardItemType.Selector: vItem = new SelectorItem(); break; case HoverboardItemType.Sticky: vItem = new StickyItem(); break; case HoverboardItemType.Checkbox: var checkItem = new CheckboxItem(); checkItem.Value = CheckboxValue; vItem = checkItem; break; case HoverboardItemType.Radio: var radItem = new RadioItem(); radItem.InitDefaultGroupId(gameObject.transform); radItem.Value = RadioValue; radItem.GroupId = RadioGroupId; vItem = radItem; break; case HoverboardItemType.Slider: var sliderItem = new SliderItem(); sliderItem.Ticks = SliderTicks; sliderItem.Snaps = SliderSnaps; sliderItem.RangeMin = SliderRangeMin; sliderItem.RangeMax = SliderRangeMax; sliderItem.Value = Mathf.InverseLerp(SliderRangeMin, SliderRangeMax, SliderValue); sliderItem.AllowJump = SliderAllowJump; sliderItem.FillStartingPoint = SliderFillStartingPoint; vItem = sliderItem; break; case HoverboardItemType.Text: vItem = new TextItem(); break; default: throw new Exception("Unhandled item type: "+Type); } if ( !string.IsNullOrEmpty(Id) ) { vItem.Id = Id; } vItem.DisplayContainer = gameObject; vItem.Label = (string.IsNullOrEmpty(Label) ? gameObject.name : Label); vItem.Width = Width; vItem.Height = Height; vItem.IsVisible = IsVisible; vItem.IsEnabled = IsEnabled; }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void BuildItem() { switch ( Type ) { case HovercastItemType.Checkbox: var checkItem = new CheckboxItem(); checkItem.Value = CheckboxValue; vItem = checkItem; break; case HovercastItemType.Parent: vItem = new ParentItem(); (vItem as ParentItem).InitChildGroup(GetChildItems); break; case HovercastItemType.Radio: var radItem = new RadioItem(); radItem.InitDefaultGroupId(gameObject.transform); radItem.Value = RadioValue; vItem = radItem; break; case HovercastItemType.Selector: vItem = new SelectorItem(); break; case HovercastItemType.Slider: var sliderItem = new SliderItem(); sliderItem.Ticks = SliderTicks; sliderItem.Snaps = SliderSnaps; sliderItem.RangeMin = SliderRangeMin; sliderItem.RangeMax = SliderRangeMax; sliderItem.Value = Mathf.InverseLerp(SliderRangeMin, SliderRangeMax, SliderValue); sliderItem.AllowJump = SliderAllowJump; sliderItem.FillStartingPoint = SliderFillStartingPoint; vItem = sliderItem; break; case HovercastItemType.Sticky: vItem = new StickyItem(); break; case HovercastItemType.Text: vItem = new TextItem(); break; default: throw new Exception("Unhandled item type: "+Type); } if ( !string.IsNullOrEmpty(Id) ) { vItem.Id = Id; } vItem.DisplayContainer = gameObject; vItem.Label = (string.IsNullOrEmpty(Label) ? gameObject.name : Label); vItem.Height = RelativeSize; vItem.IsVisible = IsVisible; vItem.IsEnabled = IsEnabled; ISelectorItem selItem = (vItem as ISelectorItem); if ( selItem != null ) { selItem.NavigateBackUponSelect = NavigateBackUponSelect; } }