/*--------------------------------------------------------------------------------------------*/ 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 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; }
/*--------------------------------------------------------------------------------------------*/ private GameObject BuildRowItem(Transform pRowTx, HoverkeyBuilderKeyInfo pKeyInfo) { var itemGo = new GameObject(pKeyInfo.DefaultKey + ""); itemGo.transform.SetParent(pRowTx, false); HoverItemBuilder build = itemGo.AddComponent <HoverItemBuilder>(); build.ItemType = pKeyInfo.ItemType; build.ButtonRendererPrefab = ButtonRendererPrefab; build.SliderRendererPrefab = SliderRendererPrefab; build.OnEditorTriggerButtonSelected(); DestroyImmediate(build, false); //// HoverItemData data = itemGo.GetComponent <HoverItemData>(); data.Id = pKeyInfo.ID; data.Label = pKeyInfo.DefaultLabel; itemGo.AddComponent <HoverShapeRect>(); HoverkeyItemLabels labels = itemGo.AddComponent <HoverkeyItemLabels>(); labels.ActionType = pKeyInfo.ActionType; labels.DefaultKey = pKeyInfo.DefaultKey; labels.DefaultLabel = pKeyInfo.DefaultLabel; labels.HasShiftLabel = pKeyInfo.HasShiftLabel; labels.ShiftLabel = pKeyInfo.ShiftLabel; if (pKeyInfo.RelativeSizeX != 1) { HoverLayoutRectRelativeSizer sizer = itemGo.AddComponent <HoverLayoutRectRelativeSizer>(); sizer.RelativeSizeX = pKeyInfo.RelativeSizeX; } HoverCanvas can = itemGo.GetComponentInChildren <HoverCanvas>(); can.Alignment = HoverCanvas.CanvasAlignmentType.Center; can.PaddingX = 0.001f; //// HoverkeyInterface inter = gameObject.GetComponent <HoverkeyInterface>(); HoverItemDataSelector selData = (data as HoverItemDataSelector); HoverItemDataSticky stickyData = (data as HoverItemDataSticky); HoverItemDataCheckbox checkboxData = (data as HoverItemDataCheckbox); if (selData != null) { #if UNITY_EDITOR UnityEditor.Events.UnityEventTools.AddPersistentListener( selData.OnSelectedEvent, inter.HandleItemSelected); #else selData.OnSelectedEvent.AddListener(inter.HandleItemSelected); #endif } else if (stickyData != null) { #if UNITY_EDITOR UnityEditor.Events.UnityEventTools.AddPersistentListener( stickyData.OnSelectedEvent, inter.HandleItemSelected); UnityEditor.Events.UnityEventTools.AddPersistentListener( stickyData.OnDeselectedEvent, inter.HandleItemDeselected); #else stickyData.OnSelectedEvent.AddListener(inter.HandleItemSelected); stickyData.OnDeselectedEvent.AddListener(inter.HandleItemDeselected); #endif } else if (checkboxData != null) { #if UNITY_EDITOR UnityEditor.Events.UnityEventTools.AddPersistentListener( checkboxData.OnSelectedEvent, inter.HandleItemSelected); UnityEditor.Events.UnityEventTools.AddPersistentListener( checkboxData.OnValueChangedEvent, inter.HandleItemValueChanged); #else checkboxData.OnSelectedEvent.AddListener(inter.HandleItemSelected); checkboxData.OnValueChangedEvent.AddListener(inter.HandleItemValueChanged); #endif } return(itemGo); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public HoverLayoutRectGroupChild(ILayoutableRect pElem, HoverLayoutRectRelativeSizer pSizer) { Elem = pElem; RelSizer = pSizer; }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public HoverLayoutRectGroupChild(IRectLayoutable pElem, HoverLayoutRectRelativeSizer pSizer) { Elem = pElem; RelSizer = pSizer; }