// Use this for initialization void Start() { OS = Environment.OSVersion.ToString(); path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); if (OS.Contains("Unix")) { if (Directory.Exists(path + "/Documents/Projects/")) { filepath = path + "/Documents/Projects/"; } else { Directory.CreateDirectory(path + "/Documents/Projects"); filepath = path + "/Documents/Projects/"; } } else { if (Directory.Exists(path + "/Projects/")) { filepath = path + "/Projects/"; } else { Directory.CreateDirectory(path + "/Projects/"); filepath = path + "/Projects/"; } } string[] files = Directory.GetDirectories(@filepath); nameButtons = new string[files.Length]; radioButtons = new GameObject[files.Length]; for (int i = 0; i < files.Length; i++) { nameButtons[i] = files [i].Replace(filepath, ""); radioButtons[i] = new GameObject(nameButtons[i]); radioButtons[i].AddComponent <HoverItemDataRadio> ().Label = nameButtons[i]; HoverItemBuilder builder = radioButtons[i].AddComponent <HoverItemBuilder> (); builder.PerformBuild(); radioButtons[i].AddComponent <HoverShapeArc> (); radioButtons[i].transform.parent = gameObject.transform; radioButtons[i].transform.localPosition = Vector3.zero; } }
/*--------------------------------------------------------------------------------------------*/ private void BuildTitleItem(GameObject pItemGo) { HoverItemBuilder build = pItemGo.AddComponent <HoverItemBuilder>(); build.ItemType = HoverItem.HoverItemType.Text; build.ButtonRendererPrefab = ButtonRendererPrefab; build.PerformBuild(); //// HoverItemDataText data = pItemGo.GetComponent <HoverItemDataText>(); data.Id = "HovercastTitleItem"; data.Label = "Hovercast"; HoverShapeArc shapeArc = pItemGo.AddComponent <HoverShapeArc>(); shapeArc.OuterRadius = 0.075f; shapeArc.InnerRadius = 0.015f; shapeArc.ArcDegrees = 90; }
/*--------------------------------------------------------------------------------------------*/ private void BuildBackItem(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 = "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 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 <HoverRendererIndicatorOverrider>(); }
/*--------------------------------------------------------------------------------------------*/ private GameObject BuildRowItem(GameObject pRowGo, string pId, string pLabel, HoverItem.HoverItemType pType) { var itemGo = new GameObject("Item" + pLabel); itemGo.transform.SetParent(pRowGo.transform, false); HoverItemBuilder build = itemGo.AddComponent <HoverItemBuilder>(); build.ItemType = pType; build.ButtonRendererPrefab = ButtonRendererPrefab; build.SliderRendererPrefab = SliderRendererPrefab; build.PerformBuild(); itemGo.AddComponent <HoverShapeRect>(); HoverItemData data = itemGo.GetComponent <HoverItemData>(); data.Id = pId; data.Label = pLabel; 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; }
/*--------------------------------------------------------------------------------------------*/ 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.PerformBuild(); //// 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); }