/*--------------------------------------------------------------------------------------------*/ private static T BuildRenderer <T>(Transform pParentTx, GameObject pPrefab, string pDisplayTypeName, Type pDefaultType) where T : class, IGameObjectProvider { if (pPrefab != null) { T prefabRend = TryBuildPrefabRenderer <T>(pPrefab); if (prefabRend != null) { prefabRend.gameObject.transform.SetParent(pParentTx, false); TreeUpdater treeUp = prefabRend.gameObject.GetComponent <TreeUpdater>(); if (treeUp != null) { treeUp.Update(); } return(prefabRend); } Debug.LogError(pDisplayTypeName + " prefab '" + pPrefab.name + "' must contain a '" + typeof(T) + "' component. ", pParentTx); } Debug.LogWarning("Could not find existing renderer, and no prefab provided.", pParentTx); return(default(T)); }
/*--------------------------------------------------------------------------------------------*/ private void BuildCursor(HoverCursorDataProvider pProv, ICursorData pData) { var curGo = new GameObject(pData.Type + ""); curGo.transform.SetParent(gameObject.transform, false); TreeUpdater treeUp = curGo.AddComponent <TreeUpdater>(); HoverCursorFollower follow = curGo.AddComponent <HoverCursorFollower>(); follow.CursorDataProvider = pProv; follow.CursorType = pData.Type; follow.FollowCursorActive = false; follow.ScaleUsingCursorSize = true; HoverRendererCursorUpdater cursRendUp = curGo.AddComponent <HoverRendererCursorUpdater>(); cursRendUp.CursorRendererPrefab = CursorRendererPrefab; if (pData.Idle != null) { HoverRendererIdleUpdater idleRendUp = curGo.AddComponent <HoverRendererIdleUpdater>(); idleRendUp.IdleRendererPrefab = IdleRendererPrefab; } follow.Update(); //moves interface to the correct cursor transform treeUp.Update(); //force renderer creation }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ 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 PerformBuild() { gameObject.AddComponent <HoverkeyInterface>(); gameObject.AddComponent <HoverkeyTextInput>(); BuildMain(); BuildFunctions(); BuildThree(); BuildSix(); BuildArrows(); BuildNumpad(); TreeUpdater treeUp = gameObject.AddComponent <TreeUpdater>(); treeUp.Update(); //force entire interface update DestroyImmediate(treeUp, false); //remove the updater }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public void PerformBuild() { TreeUpdater treeUp = gameObject.AddComponent <TreeUpdater>(); HoverItem item = gameObject.AddComponent <HoverItem>(); item.ItemType = ItemType; HoverItemHighlightState highState = gameObject.AddComponent <HoverItemHighlightState>(); gameObject.AddComponent <HoverItemSelectionState>(); HoverItemRendererUpdater rendUp = gameObject.AddComponent <HoverItemRendererUpdater>(); rendUp.ButtonRendererPrefab = ButtonRendererPrefab; rendUp.SliderRendererPrefab = SliderRendererPrefab; highState.ProximityProvider = rendUp; treeUp.Update(); //forces the entire item to update }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ 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 }