//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public override void TreeUpdate() { HovercastOpenTransitioner open = gameObject.GetComponent <HovercastOpenTransitioner>(); HovercastRowTransitioner row = gameObject.GetComponent <HovercastRowTransitioner>(); HovercastInterface cast = gameObject.GetComponent <HovercastInterface>(); bool preventHigh = (open.IsTransitionActive || row.IsTransitionActive); UpdateItem(cast.OpenItem, row.IsTransitionActive); UpdateItem(cast.BackItem, preventHigh); UpdateItem(cast.TitleItem, preventHigh); UpdateRow(cast.PreviousRow, preventHigh); UpdateRow(cast.ActiveRow, preventHigh); }
/*--------------------------------------------------------------------------------------------*/ private void UpdateWithTransitions() { HovercastOpenTransitioner open = gameObject.GetComponent <HovercastOpenTransitioner>(); HovercastRowTransitioner row = gameObject.GetComponent <HovercastRowTransitioner>(); HovercastInterface cast = gameObject.GetComponent <HovercastInterface>(); float openProg = open.TransitionProgressCurved; float openAlpha = (cast.IsOpen ? openProg : 1 - openProg); float prevAlpha = openAlpha * (1 - row.TransitionProgressCurved); float activeAlpha = openAlpha * row.TransitionProgressCurved; FadeItem(cast.OpenItem, 1); FadeItem(cast.BackItem, openAlpha); FadeItem(cast.TitleItem, openAlpha); FadeRow(cast.PreviousRow, prevAlpha); FadeRow(cast.ActiveRow, activeAlpha); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public void PerformBuild() { TreeUpdater treeUp = gameObject.AddComponent <TreeUpdater>(); HoverCursorFollower follow = gameObject.AddComponent <HoverCursorFollower>(); HovercastInterface inter = gameObject.AddComponent <HovercastInterface>(); //// var adjustGo = new GameObject("TransformAdjuster"); adjustGo.transform.SetParent(transform, false); adjustGo.transform.localPosition = new Vector3(0, 0, 0.02f); adjustGo.transform.localRotation = Quaternion.Euler(0, 180, 80); var openItemGo = new GameObject("OpenItem"); openItemGo.transform.SetParent(adjustGo.transform, false); openItemGo.transform.localPosition = new Vector3(0, -0.05f, 0); var titleItemGo = new GameObject("TitleItem"); titleItemGo.transform.SetParent(adjustGo.transform, false); var backItemGo = new GameObject("BackItem"); backItemGo.transform.SetParent(adjustGo.transform, false); var rowContGo = new GameObject("Rows"); rowContGo.transform.SetParent(adjustGo.transform, false); rowContGo.AddComponent <TreeUpdater>(); var row0Go = new GameObject("Root"); row0Go.transform.SetParent(rowContGo.transform, false); //// BuildOpenItem(openItemGo); BuildTitleItem(titleItemGo); BuildBackItem(backItemGo); BuildRow(row0Go, "Hovercast"); if (IncludeExampleRows) { BuildExampleRows(rowContGo, row0Go); } adjustGo.AddComponent <TreeUpdater>(); //after building items //// follow.CursorType = (AttachToLeftHand ? CursorType.LeftPalm : CursorType.RightPalm); follow.ObjectsToActivate = new[] { openItemGo, titleItemGo, backItemGo, rowContGo }; inter.RowContainer = rowContGo.transform; inter.ActiveRow = row0Go.GetComponent <HoverLayoutArcRow>(); inter.OpenItem = openItemGo.GetComponent <HoverItemDataSelector>(); inter.TitleItem = titleItemGo.GetComponent <HoverItemDataText>(); inter.BackItem = backItemGo.GetComponent <HoverItemDataSelector>(); HovercastOpenTransitioner openTrans = gameObject.AddComponent <HovercastOpenTransitioner>(); HovercastRowTransitioner rowTrans = gameObject.AddComponent <HovercastRowTransitioner>(); rowTrans.RowEntryTransition = HovercastRowSwitchingInfo.RowEntryType.FromInside; #if UNITY_EDITOR UnityEditor.Events.UnityEventTools.AddPersistentListener( inter.OnOpenToggledEvent, openTrans.OnOpenToggled); UnityEditor.Events.UnityEventTools.AddPersistentListener( inter.OnRowSwitchedEvent, rowTrans.OnRowSwitched); #else inter.OnOpenToggledEvent.AddListener(openTrans.OnOpenToggled); inter.OnRowSwitchedEvent.AddListener(rowTrans.OnRowSwitched); #endif gameObject.AddComponent <HovercastHighlightPreventer>(); HovercastBackCursorTrigger backTrig = gameObject.AddComponent <HovercastBackCursorTrigger>(); backTrig.BackTriggerCursorType = follow.CursorType; HovercastActiveDirection actDir = gameObject.AddComponent <HovercastActiveDirection>(); actDir.ChildForActivation = adjustGo; HovercastMirrorSwitcher mirror = gameObject.AddComponent <HovercastMirrorSwitcher>(); mirror.UseMirrorLayout = !AttachToLeftHand; gameObject.AddComponent <HovercastAlphaUpdater>(); if (AutoRotateHandToFaceCamera) { HoverCursorDataProvider curDataProv = FindObjectOfType <HoverCursorDataProvider>(); ICursorDataForInput curData = curDataProv.GetCursorDataForInput(follow.CursorType); float addRotZ = 80 * (AttachToLeftHand ? 1 : -1); actDir.TreeUpdate(); //forces search for the "facing" transform curData.transform.LookAt(actDir.ActiveWhenFacingTransform, Vector3.up); curData.transform.localRotation *= Quaternion.Euler(0, 0, addRotZ); } follow.Update(); //moves interface to the correct cursor transform treeUp.Update(); //forces entire interface to update }