/*--------------------------------------------------------------------------------------------*/ 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; } }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void UpdateWithTransitions() { HoverpanelRowTransitioner row = gameObject.GetComponent <HoverpanelRowTransitioner>(); HoverpanelInterface panel = gameObject.GetComponent <HoverpanelInterface>(); FadeRow(panel.PreviousRow, 1 - row.TransitionProgressCurved); FadeRow(panel.ActiveRow, row.TransitionProgressCurved); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public override void TreeUpdate() { HoverpanelInterface panel = GetComponent <HoverpanelInterface>(); HoverShapeRect shape = GetComponent <HoverShapeRect>(); UpdateRow(panel.ActiveRow, shape); UpdateRow(panel.PreviousRow, shape); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public override void TreeUpdate() { HoverpanelRowTransitioner row = gameObject.GetComponent <HoverpanelRowTransitioner>(); HoverpanelInterface panel = gameObject.GetComponent <HoverpanelInterface>(); bool preventHigh = (row.IsTransitionActive); UpdateRow(panel.PreviousRow, preventHigh); UpdateRow(panel.ActiveRow, preventHigh); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public void Start() { HoverpanelInterface panel = GetComponent <HoverpanelInterface>(); foreach (Transform childTx in panel.transform) { HoverLayoutRectRow row = childTx.GetComponent <HoverLayoutRectRow>(); if (row != null && row != panel.ActiveRow) { childTx.gameObject.SetActive(false); } } }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public void PerformBuild() { TreeUpdater treeUp = gameObject.AddComponent <TreeUpdater>(); HoverShapeRect shapeRect = gameObject.AddComponent <HoverShapeRect>(); HoverpanelInterface inter = gameObject.AddComponent <HoverpanelInterface>(); //// treeUp.enabled = false; var row0Go = new GameObject("RowRoot"); row0Go.transform.SetParent(gameObject.transform, false); BuildRow(row0Go); if (IncludeExampleRows) { BuildExampleRows(row0Go); } treeUp.enabled = true; //// shapeRect.SizeX = 0.3f; shapeRect.SizeY = 0.2f; inter.ActiveRow = row0Go.GetComponent <HoverLayoutRectRow>(); gameObject.AddComponent <HoverpanelRowSizer>(); HoverpanelRowTransitioner rowTrans = gameObject.AddComponent <HoverpanelRowTransitioner>(); rowTrans.RowEntryTransition = HoverpanelRowSwitchingInfo.RowEntryType.SlideFromTop; #if UNITY_EDITOR UnityEditor.Events.UnityEventTools.AddPersistentListener( inter.OnRowSwitchedEvent, rowTrans.OnRowSwitched); #else inter.OnRowSwitchedEvent.AddListener(rowTrans.OnRowSwitched); #endif gameObject.AddComponent <HoverpanelHighlightPreventer>(); gameObject.AddComponent <HoverpanelActiveDirection>(); gameObject.AddComponent <HoverpanelAlphaUpdater>(); treeUp.Update(); //forces entire interface to update }
/*--------------------------------------------------------------------------------------------*/ public void TreeUpdate() { UpdateFacingTransform(); HoverpanelInterface panel = GetComponent <HoverpanelInterface>(); HoverpanelRowTransitioner trans = GetComponent <HoverpanelRowTransitioner>(); if (OnlyDuringTransitions && !trans.IsTransitionActive) { return; } UpdateRow(panel.ActiveRow); UpdateRow(panel.PreviousRow); Controllers.TryExpireControllers(); }
/*--------------------------------------------------------------------------------------------*/ private void UpdateRows() { HoverpanelInterface panel = GetComponent <HoverpanelInterface>(); HoverShapeRect shape = GetComponent <HoverShapeRect>(); bool isTransitionDone = (TransitionProgress >= 1); var posScale = new Vector3(shape.SizeX, shape.SizeY, DepthDistance); Vector3 activeFromLocalPos = Vector3.zero; Vector3 prevToLocalPos = Vector3.zero; Quaternion activeFromLocalRot = Quaternion.identity; Quaternion prevToLocalRot = Quaternion.identity; TransitionProgressCurved = 1 - Mathf.Pow(1 - TransitionProgress, TransitionExponent); if (!isTransitionDone) { switch (RowEntryTransition) { case HoverpanelRowSwitchingInfo.RowEntryType.SlideFromTop: activeFromLocalPos = Vector3.up; prevToLocalPos = Vector3.down; break; case HoverpanelRowSwitchingInfo.RowEntryType.SlideFromBottom: activeFromLocalPos = Vector3.down; prevToLocalPos = Vector3.up; break; case HoverpanelRowSwitchingInfo.RowEntryType.SlideFromLeft: activeFromLocalPos = Vector3.left; prevToLocalPos = Vector3.right; break; case HoverpanelRowSwitchingInfo.RowEntryType.SlideFromRight: activeFromLocalPos = Vector3.right; prevToLocalPos = Vector3.left; break; case HoverpanelRowSwitchingInfo.RowEntryType.SlideFromFront: activeFromLocalPos = Vector3.back; prevToLocalPos = Vector3.forward; break; case HoverpanelRowSwitchingInfo.RowEntryType.SlideFromBack: activeFromLocalPos = Vector3.forward; prevToLocalPos = Vector3.back; break; case HoverpanelRowSwitchingInfo.RowEntryType.RotateFromTop: activeFromLocalRot = RotateNegX; prevToLocalRot = RotatePosX; break; case HoverpanelRowSwitchingInfo.RowEntryType.RotateFromBottom: activeFromLocalRot = RotatePosX; prevToLocalRot = RotateNegX; break; case HoverpanelRowSwitchingInfo.RowEntryType.RotateFromLeft: activeFromLocalRot = RotateNegY; prevToLocalRot = RotatePosY; break; case HoverpanelRowSwitchingInfo.RowEntryType.RotateFromRight: activeFromLocalRot = RotatePosY; prevToLocalRot = RotateNegY; break; } } panel.ActiveRow.Controllers.Set(SettingsControllerMap.GameObjectActiveSelf, this); panel.ActiveRow.Controllers.Set(SettingsControllerMap.TransformLocalPosition, this); panel.ActiveRow.Controllers.Set(SettingsControllerMap.TransformLocalRotation, this); panel.ActiveRow.gameObject.SetActive(true); activeFromLocalPos = Vector3.Scale(activeFromLocalPos, posScale); panel.ActiveRow.transform.localPosition = Vector3.Lerp(activeFromLocalPos, Vector3.zero, TransitionProgressCurved); panel.ActiveRow.transform.localRotation = Quaternion.Slerp(activeFromLocalRot, Quaternion.identity, TransitionProgressCurved); if (panel.PreviousRow == null) { return; } panel.PreviousRow.Controllers.Set(SettingsControllerMap.GameObjectActiveSelf, this); panel.PreviousRow.Controllers.Set(SettingsControllerMap.TransformLocalPosition, this); panel.PreviousRow.Controllers.Set(SettingsControllerMap.TransformLocalRotation, this); panel.PreviousRow.gameObject.SetActive(!isTransitionDone); prevToLocalPos = Vector3.Scale(prevToLocalPos, posScale); panel.PreviousRow.transform.localPosition = Vector3.Lerp(Vector3.zero, prevToLocalPos, TransitionProgressCurved); panel.PreviousRow.transform.localRotation = Quaternion.Slerp(Quaternion.identity, prevToLocalRot, TransitionProgressCurved); }