/*--------------------------------------------------------------------------------------------*/ private void BuildRowNavItem(GameObject pRowGo, string pId, string pLabel, GameObject pNavToRowGo) { GameObject itemGo = BuildRowItem(pRowGo, pId, pLabel, HoverItem.HoverItemType.Selector); HoverpanelInterface inter = gameObject.GetComponent <HoverpanelInterface>(); bool isBack = (pNavToRowGo == null); HoverItemDataSelector data = itemGo.GetComponent <HoverItemDataSelector>(); data.Action = (isBack ? SelectorActionType.NavigateOut : SelectorActionType.NavigateIn); #if UNITY_EDITOR UnityEditor.Events.UnityEventTools.AddPersistentListener( data.OnSelectedEvent, inter.OnRowSwitched); #else data.OnSelectedEvent.AddListener(inter.OnRowSwitched); #endif HoverpanelRowSwitchingInfo rowSwitch = itemGo.AddComponent <HoverpanelRowSwitchingInfo>(); rowSwitch.NavigateBack = isBack; rowSwitch.NavigateToRow = (isBack ? null : pNavToRowGo.GetComponent <HoverLayoutRectRow>()); rowSwitch.RowEntryTransition = (isBack ? HoverpanelRowSwitchingInfo.RowEntryType.SlideFromFront : HoverpanelRowSwitchingInfo.RowEntryType.SlideFromBack ); if (!isBack) { HoverCanvas can = itemGo.GetComponentInChildren <HoverCanvas>(); can.Alignment = HoverCanvas.CanvasAlignmentType.TextLeftAndIconRight; } }
/*--------------------------------------------------------------------------------------------*/ private void UpdateChildCanvas(HoverCanvas pChildCanvas, float pAlpha) { if (pChildCanvas == null) { return; } pChildCanvas.Controllers.Set(SettingsControllerMap.CanvasSortingLayer, this); pChildCanvas.Controllers.Set(SettingsControllerMap.CanvasGroupAlpha, this); pChildCanvas.CanvasComponent.sortingLayerName = SortingLayer; pChildCanvas.CanvasGroupComponent.alpha = pAlpha; }
/*--------------------------------------------------------------------------------------------*/ private void BuildBackItem(GameObject pItemGo) { HoverItemBuilder build = pItemGo.AddComponent <HoverItemBuilder>(); build.ItemType = HoverItem.HoverItemType.Selector; build.ButtonRendererPrefab = ButtonRendererPrefab; build.OnEditorTriggerButtonSelected(); DestroyImmediate(build, false); //// HovercastInterface inter = gameObject.GetComponent <HovercastInterface>(); HoverItemDataSelector data = pItemGo.GetComponent <HoverItemDataSelector>(); data.Id = "HovercastBackItem"; data.Label = ""; data.Action = SelectorActionType.NavigateOut; #if UNITY_EDITOR UnityEditor.Events.UnityEventTools.AddPersistentListener( data.OnSelectedEvent, inter.OnRowSwitched); #else data.OnSelectedEvent.AddListener(inter.OnRowSwitched); #endif HoverFillButtonArcUpdater fillArcUp = pItemGo.GetComponentInChildren <HoverFillButtonArcUpdater>(); fillArcUp.EdgePosition = HoverFillButtonArcUpdater.EdgePositionType.Outer; HoverCanvas can = pItemGo.GetComponentInChildren <HoverCanvas>(); can.Alignment = HoverCanvas.CanvasAlignmentType.Custom; can.IconOuter.transform.localPosition = new Vector3(-40, 0, 0); HoverShapeArc shapeArc = pItemGo.AddComponent <HoverShapeArc>(); shapeArc.OuterRadius = 0.015f; shapeArc.InnerRadius = 0; shapeArc.ArcDegrees = 360; HovercastRowSwitchingInfo rowSwitch = pItemGo.AddComponent <HovercastRowSwitchingInfo>(); rowSwitch.NavigateBack = true; rowSwitch.RowEntryTransition = HovercastRowSwitchingInfo.RowEntryType.FromInside; pItemGo.AddComponent <HoverIndicatorOverrider>(); }
/*--------------------------------------------------------------------------------------------*/ private void PerformSwitch() { HovercastInterface cast = GetComponent <HovercastInterface>(); Transform adjustTx = cast.transform.GetChild(0); Vector3 flipY = new Vector3(1, -1, 1); Vector3 flipZ = new Vector3(1, 1, -1); Quaternion spinRotZ = Quaternion.Euler(0, 0, 180); //// adjustTx.localRotation = Quaternion.Euler( Vector3.Scale(adjustTx.localRotation.eulerAngles, flipZ)); adjustTx.localScale = Vector3.Scale(adjustTx.localScale, flipY); //// cast.BackItem.transform.localRotation *= spinRotZ; cast.TitleItem.transform.localRotation *= spinRotZ; cast.OpenItem.transform.localRotation *= spinRotZ; cast.RowContainer.transform.localRotation *= spinRotZ; cast.OpenItem.transform.localPosition = Vector3.Scale(cast.OpenItem.transform.localPosition, flipY); //// cast.GetComponentsInChildren(true, vHoverCanvases); for (int i = 0; i < vHoverCanvases.Count; i++) { HoverCanvas can = vHoverCanvases[i]; can.UseMirrorLayout = !can.UseMirrorLayout; #if UNITY_EDITOR //force serialization of changes made outside of the renderer prefab UnityEditor.EditorUtility.SetDirty(can); #endif } }
/*--------------------------------------------------------------------------------------------*/ 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); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void BuildOpenItem(GameObject pItemGo) { HoverItemBuilder build = pItemGo.AddComponent <HoverItemBuilder>(); build.ItemType = HoverItem.HoverItemType.Selector; build.ButtonRendererPrefab = ButtonRendererPrefab; build.PerformBuild(); //// HovercastInterface inter = gameObject.GetComponent <HovercastInterface>(); HoverItemDataSelector data = pItemGo.GetComponent <HoverItemDataSelector>(); data.Id = "HovercastOpenItem"; data.Label = ""; #if UNITY_EDITOR UnityEditor.Events.UnityEventTools.AddPersistentListener( data.OnSelectedEvent, inter.OnOpenToggled); #else data.OnSelectedEvent.AddListener(inter.OnRowSwitched); #endif HoverCanvas can = pItemGo.GetComponentInChildren <HoverCanvas>(); var iconPivotGo = new GameObject("IconPivot"); iconPivotGo.transform.SetParent(can.transform, false); var iconOpenGo = new GameObject("IconOpen"); iconOpenGo.transform.SetParent(iconPivotGo.transform, false); var iconCloseGo = new GameObject("IconClose"); iconCloseGo.transform.SetParent(iconPivotGo.transform, false); RectTransform iconPivotRectTx = iconPivotGo.AddComponent <RectTransform>(); iconPivotRectTx.localPosition = new Vector3(-47.5f, 0, 0); iconPivotRectTx.localScale = new Vector3(2.2f, 2.2f, 1); iconPivotRectTx.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 100); iconPivotRectTx.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 100); RectTransform iconOpenRectTx = iconOpenGo.AddComponent <RectTransform>(); iconOpenRectTx.localPosition = new Vector3(19, 0, 0); iconOpenRectTx.localRotation = Quaternion.Euler(0, 0, -45); iconOpenRectTx.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 40); iconOpenRectTx.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 40); RectTransform iconCloseRectTx = iconCloseGo.AddComponent <RectTransform>(); iconCloseRectTx.localPosition = new Vector3(19, 0, 0); iconCloseRectTx.localRotation = Quaternion.Euler(0, 0, -45); iconCloseRectTx.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 40); iconCloseRectTx.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 40); RawImage openImage = iconOpenGo.AddComponent <RawImage>(); openImage.material = Resources.Load <Material>("Materials/HovercastIconsMaterial"); openImage.uvRect = new Rect(0.002f, 0.002f, 0.496f, 0.996f); RawImage closeImage = iconCloseGo.AddComponent <RawImage>(); closeImage.material = openImage.material; closeImage.uvRect = new Rect(0.502f, 0.002f, 0.496f, 0.996f); //// HoverShapeArc shapeArc = pItemGo.AddComponent <HoverShapeArc>(); shapeArc.OuterRadius = 0.02f; shapeArc.InnerRadius = 0; shapeArc.ArcDegrees = 360; HovercastOpenIcons icons = pItemGo.AddComponent <HovercastOpenIcons>(); icons.OpenIcon = iconOpenGo; icons.CloseIcon = iconCloseGo; }