/*--------------------------------------------------------------------------------------------*/ public void OnRowSwitched(IItemDataSelectable pItemData) { HovercastRowSwitchingInfo switchInfo = pItemData.gameObject.GetComponent <HovercastRowSwitchingInfo>(); if (switchInfo == null) { Debug.LogError("Selected item requires a '" + typeof(HovercastRowSwitchingInfo).Name + "' component.", pItemData.gameObject); return; } if (PreviousRow != null) { PreviousRow.gameObject.SetActive(false); } if (switchInfo.NavigateBack) { NavigateBack(switchInfo.RowEntryTransition); } else { NavigateToRow(switchInfo.NavigateToRow, switchInfo.RowEntryTransition); } }
/*--------------------------------------------------------------------------------------------*/ private void BuildRowNavItem(GameObject pRowGo, string pId, string pLabel, GameObject pNavToRowGo) { GameObject itemGo = BuildRowItem(pRowGo, pId, pLabel, HoverItem.HoverItemType.Selector); HovercastInterface inter = gameObject.GetComponent <HovercastInterface>(); bool isBack = (pNavToRowGo == null); HoverItemDataSelector data = itemGo.GetComponent <HoverItemDataSelector>(); data.Action = (isBack ? SelectorActionType.NavigateOut : SelectorActionType.NavigateIn); #if UNITY_EDITOR UnityEditor.Events.UnityEventTools.AddPersistentListener( data.OnSelectedEvent, inter.OnRowSwitched); #else data.OnSelectedEvent.AddListener(inter.OnRowSwitched); #endif HovercastRowSwitchingInfo rowSwitch = itemGo.AddComponent <HovercastRowSwitchingInfo>(); rowSwitch.NavigateBack = isBack; rowSwitch.NavigateToRow = (isBack ? null : pNavToRowGo.GetComponent <HoverLayoutArcRow>()); rowSwitch.RowEntryTransition = (isBack ? HovercastRowSwitchingInfo.RowEntryType.FromInside : HovercastRowSwitchingInfo.RowEntryType.FromOutside ); if (!isBack) { HoverCanvas can = itemGo.GetComponentInChildren <HoverCanvas>(); can.Alignment = HoverCanvas.CanvasAlignmentType.TextLeftAndIconRight; } }
/*--------------------------------------------------------------------------------------------*/ private void BuildBackItem(GameObject pItemGo) { HoverItemBuilder build = pItemGo.AddComponent <HoverItemBuilder>(); build.ItemType = HoverItem.HoverItemType.Selector; build.ButtonRendererPrefab = ButtonRendererPrefab; build.OnEditorTriggerButtonSelected(); DestroyImmediate(build, false); //// HovercastInterface inter = gameObject.GetComponent <HovercastInterface>(); HoverItemDataSelector data = pItemGo.GetComponent <HoverItemDataSelector>(); data.Id = "HovercastBackItem"; data.Label = ""; data.Action = SelectorActionType.NavigateOut; #if UNITY_EDITOR UnityEditor.Events.UnityEventTools.AddPersistentListener( data.OnSelectedEvent, inter.OnRowSwitched); #else data.OnSelectedEvent.AddListener(inter.OnRowSwitched); #endif HoverFillButtonArcUpdater fillArcUp = pItemGo.GetComponentInChildren <HoverFillButtonArcUpdater>(); fillArcUp.EdgePosition = HoverFillButtonArcUpdater.EdgePositionType.Outer; HoverCanvas can = pItemGo.GetComponentInChildren <HoverCanvas>(); can.Alignment = HoverCanvas.CanvasAlignmentType.Custom; can.IconOuter.transform.localPosition = new Vector3(-40, 0, 0); HoverShapeArc shapeArc = pItemGo.AddComponent <HoverShapeArc>(); shapeArc.OuterRadius = 0.015f; shapeArc.InnerRadius = 0; shapeArc.ArcDegrees = 360; HovercastRowSwitchingInfo rowSwitch = pItemGo.AddComponent <HovercastRowSwitchingInfo>(); rowSwitch.NavigateBack = true; rowSwitch.RowEntryTransition = HovercastRowSwitchingInfo.RowEntryType.FromInside; pItemGo.AddComponent <HoverIndicatorOverrider>(); }