////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		private void BuildItem() {
			switch ( Type ) {
				case NavItem.ItemType.Checkbox:
					vItem = new NavItemCheckbox();
					break;

				case NavItem.ItemType.Parent:
					vItem = new NavItemParent(GetChildItems);
					break;

				case NavItem.ItemType.Radio:
					vItem = new NavItemRadio();
					break;

				case NavItem.ItemType.Selector:
					vItem = new NavItemSelector();
					break;

				case NavItem.ItemType.Slider:
					vItem = new NavItemSlider();
					break;

				case NavItem.ItemType.Sticky:
					vItem = new NavItemSticky();
					break;
			}
		}
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		private void HandleValueChanged(NavItem<float> pNavItem) {
			Color col = DemoEnvironment.HsvToColor(vHueSlider.RangeValue, 1, 0.666f);

			Color colFade = col;
			colFade.a = 0.25f;

			SegmentSettings.Fill(vRootSettings, vHueSettings);
			vHueSettings.SelectionColor = col;
			vHueSettings.SliderTrackColor = colFade;
			vHueSettings.SliderFillColor = colFade;
		}
Exemplo n.º 3
0
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		private void HandleItemSelected(NavLevel pLevel, NavItem pItem) {
			OnItemSelection(pLevel, pItem);

			if ( pItem.Type == NavItem.ItemType.Parent ) {
				vHistory.Push(vCurrLevel);
				SetNewLevel(pItem.ChildLevel, 1);
				return;
			}

			if ( pItem.NavigateBackUponSelect ) {
				Back();
			}
		}
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		public Type GetRendererForNavItemType(NavItem.ItemType pNavItemType) {
			Type type = GetRendererForNavItemTypeInner(pNavItemType);

			if ( type == null ) {
				throw new Exception(GetErrorPrefix(pNavItemType)+"cannot be null.");
			}

			if ( !type.GetInterfaces().Contains(typeof(IUiSegmentRenderer)) ) {
				throw new Exception(GetErrorPrefix(pNavItemType)+"must implement the "+
					typeof(IUiSegmentRenderer).Name+" interface.");
			}

			return type;
		}
Exemplo n.º 5
0
        /*--------------------------------------------------------------------------------------------*/
        protected virtual void DeselectRadioSiblings(NavItem pSelectedItem)
        {
            foreach (NavItem item in vItems)
            {
                if (item == pSelectedItem)
                {
                    continue;
                }

                NavItemRadio radItem = (item as NavItemRadio);

                if (radItem == null)
                {
                    continue;
                }

                radItem.Value = false;
            }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        internal static NavItem[] GetChildItems(GameObject pParentObj)
        {
            Transform tx         = pParentObj.transform;
            int       childCount = tx.childCount;
            var       items      = new List <NavItem>();

            for (int i = 0; i < childCount; ++i)
            {
                HovercastNavItem hni  = tx.GetChild(i).GetComponent <HovercastNavItem>();
                NavItem          item = hni.GetItem();

                if (!item.IsVisible)
                {
                    continue;
                }

                items.Add(item);
            }

            return(items.ToArray());
        }
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		protected override Type GetRendererForNavItemTypeInner(NavItem.ItemType pNavItemType) {
			switch ( pNavItemType ) {
				case NavItem.ItemType.Parent:
					return typeof(UiParentRenderer);

				case NavItem.ItemType.Selector:
					return typeof(UiSelectRenderer);

				case NavItem.ItemType.Sticky:
					return typeof(UiStickyRenderer);

				case NavItem.ItemType.Checkbox:
					return typeof(UiCheckboxRenderer);

				case NavItem.ItemType.Radio:
					return typeof(UiRadioRenderer);

				case NavItem.ItemType.Slider:
					return typeof(UiSliderRenderer);
			}

			return typeof(UiSelectRenderer);
		}
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		public SegmentState(NavItem pNavItem, InteractionSettings pSettings) {
			NavItem = pNavItem;
			vSettings = pSettings;
		}
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		private static string GetErrorPrefix(NavItem.ItemType pNavItemType) {
			return "Hovercast | The 'Segment' Renderer for '"+pNavItemType+"' NavItems ";
		}
		/*--------------------------------------------------------------------------------------------*/
		protected abstract Type GetRendererForNavItemTypeInner(NavItem.ItemType pNavItemType);
		/*--------------------------------------------------------------------------------------------*/
		protected override Type GetRendererForNavItemTypeInner(NavItem.ItemType pNavItemType) {
			return typeof(UiSliderRenderer);
		}