Example #1
0
        /*--------------------------------------------------------------------------------------------*/
        private void BuildRowNavItem(GameObject pRowGo, string pId, string pLabel,
                                     GameObject pNavToRowGo)
        {
            GameObject          itemGo = BuildRowItem(pRowGo, pId, pLabel, HoverItem.HoverItemType.Selector);
            HoverpanelInterface inter  = gameObject.GetComponent <HoverpanelInterface>();
            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

            HoverpanelRowSwitchingInfo rowSwitch = itemGo.AddComponent <HoverpanelRowSwitchingInfo>();
            rowSwitch.NavigateBack       = isBack;
            rowSwitch.NavigateToRow      = (isBack ? null : pNavToRowGo.GetComponent <HoverLayoutRectRow>());
            rowSwitch.RowEntryTransition = (isBack ?
                                            HoverpanelRowSwitchingInfo.RowEntryType.SlideFromFront :
                                            HoverpanelRowSwitchingInfo.RowEntryType.SlideFromBack
                                            );

            if (!isBack)
            {
                HoverCanvas can = itemGo.GetComponentInChildren <HoverCanvas>();
                can.Alignment = HoverCanvas.CanvasAlignmentType.TextLeftAndIconRight;
            }
        }
Example #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public void OnRowSwitched(IItemDataSelectable pItemData)
        {
            HoverpanelRowSwitchingInfo switchInfo =
                pItemData.gameObject.GetComponent <HoverpanelRowSwitchingInfo>();

            if (switchInfo == null)
            {
                Debug.LogError("Selected item requires a '" +
                               typeof(HoverpanelRowSwitchingInfo).Name + "' component.", pItemData.gameObject);
                return;
            }

            if (PreviousRow != null)
            {
                PreviousRow.gameObject.SetActive(false);
            }

            if (switchInfo.NavigateBack)
            {
                NavigateBack(switchInfo.RowEntryTransition);
            }
            else
            {
                NavigateToRow(switchInfo.NavigateToRow, switchInfo.RowEntryTransition);
            }
        }