//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void UpdateDirectionAlpha() { HovercastActiveDirection activeDir = gameObject.GetComponent <HovercastActiveDirection>(); vDirectionAlpha = Mathf.InverseLerp(activeDir.InactiveOutsideDegree, activeDir.FullyActiveWithinDegree, activeDir.CurrentDegree); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ 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 }