//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public void Awake() { if (ActiveRow == null) { ActiveRow = GetComponentInChildren <HoverLayoutRectRow>(); } }
/*--------------------------------------------------------------------------------------------*/ private void BuildFunctions() { var funcGo = new GameObject("Functions"); funcGo.transform.SetParent(gameObject.transform, false); funcGo.transform.localPosition = new Vector3(0.01125f, 0.105f, 0); funcGo.AddComponent <TreeUpdater>(); HoverLayoutRectRow rectRow = funcGo.AddComponent <HoverLayoutRectRow>(); rectRow.Arrangement = HoverLayoutRectRow.ArrangementType.LeftToRight; rectRow.SizeX = 0.4425f; rectRow.SizeY = 0.03f; HoverLayoutRectPaddingSettings rectRowPad = rectRow.Padding; rectRowPad.Between = 0.0175f; rectRow.Padding = rectRowPad; BuildRowItem(funcGo.transform, HoverkeyBuilderData.FuncRow[0]); BuildRow("Row0", funcGo.transform, HoverkeyBuilderData.FuncRow, 1, 4); BuildRow("Row1", funcGo.transform, HoverkeyBuilderData.FuncRow, 5, 4); BuildRow("Row2", funcGo.transform, HoverkeyBuilderData.FuncRow, 9, 4); }
/*--------------------------------------------------------------------------------------------*/ private void BuildThree() { GameObject threeGo = BuildRow("Three", gameObject.transform, HoverkeyBuilderData.ThreeRow); threeGo.transform.localPosition = new Vector3(0.3f, 0.105f, 0); HoverLayoutRectRow rectRow = threeGo.GetComponent <HoverLayoutRectRow>(); rectRow.Arrangement = HoverLayoutRectRow.ArrangementType.LeftToRight; rectRow.SizeX = 0.09f; rectRow.SizeY = 0.03f; }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void UpdateRow(HoverLayoutRectRow pRow, HoverShapeRect pShape) { if (pRow == null) { return; } pRow.Controllers.Set(HoverLayoutRectRow.SizeXName, this); pRow.Controllers.Set(HoverLayoutRectRow.SizeYName, this); pRow.SizeX = pShape.SizeX; pRow.SizeY = pShape.SizeY; }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ 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); } } }
/*--------------------------------------------------------------------------------------------*/ private void FadeRow(HoverLayoutRectRow pRow, float pAlpha) { if (pRow == null || !pRow.gameObject.activeSelf) { return; } pRow.GetComponentsInChildren(true, vItemDataResults); for (int i = 0; i < vItemDataResults.Count; i++) { FadeItem(vItemDataResults[i], pAlpha); } }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void UpdateRow(HoverLayoutRectRow pRow, bool pPreventHighlight) { if (pRow == null || !pRow.gameObject.activeSelf) { return; } pRow.GetComponentsInChildren(true, vItemHighStateResults); for (int i = 0; i < vItemHighStateResults.Count; i++) { UpdateHighState(vItemHighStateResults[i], pPreventHighlight); } }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public void NavigateBack(HoverpanelRowSwitchingInfo.RowEntryType pRowEntry = HoverpanelRowSwitchingInfo.RowEntryType.SlideFromTop) { if (vRowHistory.Count == 0) { Debug.LogWarning("Can't navigate back. No rows left in history."); return; } PreviousRow = ActiveRow; ActiveRow = vRowHistory.Pop(); OnRowSwitchedEvent.Invoke(pRowEntry); }
/*--------------------------------------------------------------------------------------------*/ public void NavigateToRow(HoverLayoutRectRow pRow, HoverpanelRowSwitchingInfo.RowEntryType pRowEntry) { if (pRow == null) { Debug.LogError("Could not navigate to null/missing row."); return; } vRowHistory.Push(ActiveRow); PreviousRow = ActiveRow; ActiveRow = pRow; OnRowSwitchedEvent.Invoke(pRowEntry); }
/*--------------------------------------------------------------------------------------------*/ private void BuildNumpad() { var numGo = new GameObject("Numpad"); numGo.transform.SetParent(gameObject.transform, false); numGo.transform.localPosition = new Vector3(0.43f, 0, 0); numGo.AddComponent <TreeUpdater>(); HoverLayoutRectRow numRectRow = numGo.AddComponent <HoverLayoutRectRow>(); numRectRow.Arrangement = HoverLayoutRectRow.ArrangementType.TopToBottom; numRectRow.SizeX = 0.12f; numRectRow.SizeY = 0.15f; BuildRow("Row0", numGo.transform, HoverkeyBuilderData.NumRow0); //// var noKeys = new HoverkeyBuilderKeyInfo[0]; GameObject botGo = BuildRow("Bottom", numGo.transform, noKeys); HoverLayoutRectRelativeSizer botRectSizer = botGo.AddComponent <HoverLayoutRectRelativeSizer>(); botRectSizer.RelativeSizeY = 4; GameObject botLeftGo = BuildRow("Left", botGo.transform, noKeys); HoverLayoutRectRelativeSizer botLeftRectSizer = botLeftGo.AddComponent <HoverLayoutRectRelativeSizer>(); botLeftRectSizer.RelativeSizeX = 3; HoverLayoutRectRow botLeftRow = botLeftGo.GetComponent <HoverLayoutRectRow>(); botLeftRow.Arrangement = HoverLayoutRectRow.ArrangementType.TopToBottom; BuildRow("Row1", botLeftGo.transform, HoverkeyBuilderData.NumRow1); BuildRow("Row2", botLeftGo.transform, HoverkeyBuilderData.NumRow2); BuildRow("Row3", botLeftGo.transform, HoverkeyBuilderData.NumRow3); BuildRow("Row4", botLeftGo.transform, HoverkeyBuilderData.NumRow4); GameObject botRightGo = BuildRow("Right", botGo.transform, HoverkeyBuilderData.NumCol); HoverLayoutRectRow botRightRow = botRightGo.GetComponent <HoverLayoutRectRow>(); botRightRow.Arrangement = HoverLayoutRectRow.ArrangementType.TopToBottom; }
/*--------------------------------------------------------------------------------------------*/ private void BuildSix() { var sixGo = new GameObject("Six"); sixGo.transform.SetParent(gameObject.transform, false); sixGo.transform.localPosition = new Vector3(0.3f, 0.045f, 0); sixGo.AddComponent <TreeUpdater>(); HoverLayoutRectRow rectRow = sixGo.AddComponent <HoverLayoutRectRow>(); rectRow.Arrangement = HoverLayoutRectRow.ArrangementType.TopToBottom; rectRow.SizeX = 0.09f; rectRow.SizeY = 0.06f; BuildRow("Row0", sixGo.transform, HoverkeyBuilderData.SixRow0); BuildRow("Row1", sixGo.transform, HoverkeyBuilderData.SixRow1); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void BuildMain() { var mainGo = new GameObject("Main"); mainGo.transform.SetParent(gameObject.transform, false); mainGo.transform.localPosition = new Vector3(0.01125f, 0, 0); mainGo.AddComponent <TreeUpdater>(); HoverLayoutRectRow rectRow = mainGo.AddComponent <HoverLayoutRectRow>(); rectRow.Arrangement = HoverLayoutRectRow.ArrangementType.TopToBottom; rectRow.SizeX = 0.4425f; rectRow.SizeY = 0.15f; BuildRow("Row0", mainGo.transform, HoverkeyBuilderData.MainRow0); BuildRow("Row1", mainGo.transform, HoverkeyBuilderData.MainRow1); BuildRow("Row2", mainGo.transform, HoverkeyBuilderData.MainRow2); BuildRow("Row3", mainGo.transform, HoverkeyBuilderData.MainRow3); BuildRow("Row4", mainGo.transform, HoverkeyBuilderData.MainRow4); }
/*--------------------------------------------------------------------------------------------*/ private void UpdateRow(HoverLayoutRectRow pRow) { if (pRow == null || !pRow.gameObject.activeSelf) { return; } Vector3 panelWorldNorm = pRow.transform.TransformDirection(Vector3.back); Vector3 panelToTxWorldVec = (ActiveWhenFacingTransform.position - pRow.transform.position); Vector3 panelToTxWorldDir = panelToTxWorldVec.normalized; float dotBetweenDirs = Vector3.Dot(panelWorldNorm, panelToTxWorldDir); if (dotBetweenDirs > 0) { return; } pRow.gameObject.SetActive(false); //Vector3 panelPos = pRow.transform.position; //Debug.DrawLine(panelPos, panelPos+panelWorldNorm, Color.red); //Debug.DrawLine(panelPos, panelPos+panelToTxWorldDir, Color.cyan); }
/*--------------------------------------------------------------------------------------------*/ private void BuildArrows() { var arrowsGo = new GameObject("Arrows"); arrowsGo.transform.SetParent(gameObject.transform, false); arrowsGo.transform.localPosition = new Vector3(0.3f, -0.045f, 0); arrowsGo.AddComponent <TreeUpdater>(); HoverLayoutRectRow rectRow = arrowsGo.AddComponent <HoverLayoutRectRow>(); rectRow.Arrangement = HoverLayoutRectRow.ArrangementType.TopToBottom; rectRow.SizeX = 0.09f; rectRow.SizeY = 0.06f; GameObject row0Go = BuildRow("Row0", arrowsGo.transform, HoverkeyBuilderData.Arrows, 0, 1); BuildRow("Row1", arrowsGo.transform, HoverkeyBuilderData.Arrows, 1); HoverLayoutRectRelativeSizer row0Sizer = row0Go.AddComponent <HoverLayoutRectRelativeSizer>(); row0Sizer.RelativeSizeX = 0.333f; }
/*--------------------------------------------------------------------------------------------*/ public void Start() { PreviousRow = null; }