public override UGUINode DrawImage(Data.ImgNode image, UGUINode parent) { UGUINode node = CreateRootNode(image.Name, AdjustTextRect(image.rect, image.fontSize), parent); UnityEngine.UI.Text myText = node.InitComponent <Text>(); PSDImporterUtility.SetPictureOrLoadColor(image, myText); return(node); }
public void BeginReprocess(UGUINode node) { foreach (var item in node.childs) { BeginReprocess(item); } node.InversionReprocess(); }
/// <summary> /// 普通UGUI节点 /// </summary> /// <param name="go"></param> /// <param name="rect"></param> /// <param name="parent"></param> /// <returns></returns> public UGUINode CreateNormalNode(GameObject go, Rect rect, UGUINode parent) { go.transform.SetParent(ctrl.uinode.transform, false); SetRectTransform(rect, go.transform as RectTransform); UGUINode node = new UGUINode(go.transform, parent); return(node); }
private void DrawBackground(Data.ImgNode bg, UGUINode node) { var bgnode = ctrl.DrawImage(bg, node); var graph = bgnode.InitComponent <UnityEngine.UI.Image>(); node.InitComponent <Slider>().targetGraphic = graph; PSDImporterUtility.SetPictureOrLoadColor(bg, graph); }
public override UGUINode DrawImage(ImgNode image, UGUINode parent) { UGUINode node = CreateRootNode(image.Name, image.rect, parent); UnityEngine.UI.RawImage pic = node.InitComponent <UnityEngine.UI.RawImage>(); PSDImporterUtility.SetPictureOrLoadColor(image, pic); return(node); }
public override UGUINode DrawLayer(Data.GroupNode layer, UGUINode parent) { UGUINode node = CreateRootNode(layer.displayName, layer.rect, parent); UnityEngine.UI.InputField inputfield = node.InitComponent <UnityEngine.UI.InputField>(); DrawImages(inputfield, node, layer); return(node); }
public override void AfterGenerate(UGUINode node) { base.AfterGenerate(node); ContentSizeFitter content = node.InitComponent <ContentSizeFitter>(); content.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; content.verticalFit = ContentSizeFitter.FitMode.PreferredSize; }
private void SetLayoutItem(UGUINode childNode, Rect rect) { var layout = childNode.transform.gameObject.AddComponent <LayoutElement>(); layout.preferredWidth = rect.width; layout.preferredHeight = rect.height; childNode.anchoType = AnchoType.Left | AnchoType.Up; }
public void BeginSetAnchers(UGUINode node) { foreach (var item in node.childs) { BeginSetAnchers(item); PSDImporterUtility.SetAnchorByNode(item); } }
public void BeginSetUIParents(UGUINode node) { foreach (var item in node.childs) { item.transform.SetParent(node.transform); BeginSetUIParents(item); } }
public override UGUINode DrawLayer(Data.GroupNode layer, UGUINode parent) { UGUINode node = CreateRootNode(layer.displayName, layer.rect, parent); Scrollbar scrollbar = node.InitComponent <Scrollbar>(); SetScrollBarDirection(scrollbar, layer); DrawImages(layer.images, scrollbar, node); return(node); }
public override void AfterGenerate(UGUINode node) { base.AfterGenerate(node); var dropDown = node.InitComponent <Dropdown>(); RectTransform rt = dropDown.template; rt.pivot = new Vector2(0.5f, 1); rt.anchoredPosition = Vector3.zero; }
public event UnityAction <UGUINode> inversionReprocess;//从树的末端开始处理 public UGUINode(Transform transform, UGUINode parent) { this.transform = transform; this.parent = parent; if (parent != null) { parent.childs.Add(this); } }
private void DrawFill(ImgNode fill, UGUINode node) { var fillAreaNode = CreateNormalNode(new GameObject("Fill Area", typeof(RectTransform)), fill.rect, node); var fileNode = ctrl.DrawImage(fill, fillAreaNode); fileNode.InitComponent <Image>().type = Image.Type.Tiled; node.InitComponent <Slider>().fillRect = fileNode.InitComponent <RectTransform>(); }
/// <summary> /// 空器 /// </summary> /// <param name="childNode"></param> /// <param name="scrollRect"></param> private void DrawConent(UGUINode childNode, ScrollRect scrollRect) { childNode.inversionReprocess += (x) => { var content = childNode.InitComponent <RectTransform>(); scrollRect.content = content; scrollRect.content.anchoredPosition = Vector2.zero; }; }
public PSDImportCtrl(Canvas canvas, RuleObject rule, Vector2 canvasSize) { this.canvas = canvas; this.rule = rule; this.canvas = canvas; this.canvasSize = canvasSize; uinode = new UGUINode(canvas.transform, null); InitDrawers(); }
private void DrawMask(Data.GroupNode layer, Toggle toggle, UGUINode bgNode) { var mask = layer.images.Find(x => MatchAddress(x.Name, maskAddress)); if (mask != null) { PSDImporterUtility.SetPictureOrLoadColor(mask, toggle.graphic); CreateNormalNode(toggle.graphic.gameObject, mask.rect, bgNode); } }
private void BeginScaleWithCanvas(UGUINode uinode, Vector2 uiSize) { foreach (var item in uinode.childs) { var child = item.InitComponent <RectTransform>(); child.anchorMin = Vector2.zero; child.anchorMax = Vector2.one; child.anchoredPosition = Vector2.zero; } }
private void DrawOtherLayers(GroupNode layer, UGUINode node) { for (int imageIndex = 0; imageIndex < layer.images.Count; imageIndex++) { ImgNode image = layer.images[imageIndex]; if (!MatchAddress(image.Name, rule.backgroundAddress, rule.maskAddress)) { ctrl.DrawImage(image, node); } } }
/// <summary> /// 根UGUI节点 /// </summary> /// <param name="transform"></param> /// <param name="parent"></param> protected UGUINode CreateRootNode(string name, Rect rect, UGUINode parent) { var go = CreateTemplate(); go.name = name; go.layer = LayerMask.NameToLayer("UI"); var node = CreateNormalNode(go, rect, parent); node.inversionReprocess += AfterGenerate; return(node); }
protected void StretchTitle(UGUINode node) { var texts = node.transform.GetComponentsInChildren <Text>(); var title = Array.Find(texts, x => MatchAddress(x.name, rule.titleAddress)); if (title) { PSDImporterUtility.SetNormalAnchor(AnchoType.XStretch | AnchoType.YStretch, node.transform as RectTransform, title.transform as RectTransform); title.rectTransform.anchoredPosition = Vector3.zero; } }
public override UGUINode DrawImage(Data.ImgNode image, UGUINode parent) { if (image.type == ImgType.Texture) { return(DrawRawImage(image, parent)); } else { return(DrawSpriteImage(image, parent)); } }
public override void AfterGenerate(UGUINode node) { base.AfterGenerate(node); var inputField = node.InitComponent <InputField>(); var text = inputField.textComponent.GetComponent <RectTransform>(); var holder = inputField.placeholder.GetComponent <RectTransform>(); text.anchorMin = holder.anchorMin = Vector2.zero; text.anchorMax = holder.anchorMax = Vector2.one; text.anchoredPosition = holder.anchoredPosition = Vector2.zero; text.sizeDelta = holder.sizeDelta = new Vector2(-10, -10); }
public override UGUINode DrawLayer(Data.GroupNode layer, UGUINode parent) { UGUINode node = CreateRootNode(layer.displayName, layer.rect, parent); ScrollRect scrollRect = node.InitComponent <UnityEngine.UI.ScrollRect>(); SetScrollViewDirection(layer, scrollRect, layer.directionAxis); var viewNode = DrawViewNode(layer, scrollRect, node); DrawImages(layer, node, scrollRect); DrawChildLayers(layer, viewNode, scrollRect); return(node); }
public UGUINode DrawImage(Data.ImgNode image, UGUINode parent) { UGUINode node = imgImporterDic[image.type].DrawImage(image, parent); if (node == null) { Debug.Log(image.type); Debug.Log(image); Debug.Log(parent); } return(node); }
public UGUINode[] DrawLayers(Data.GroupNode[] layers, UGUINode parent) { UGUINode[] nodes = new UGUINode[layers.Length]; if (layers != null) { for (int layerIndex = 0; layerIndex < layers.Length; layerIndex++) { nodes[layerIndex] = DrawLayer(layers[layerIndex], parent); } } return(nodes); }
public UGUINode[] DrawImages(Data.ImgNode[] images, UGUINode parent) { UGUINode[] nodes = new UGUINode[images.Length]; if (images != null) { for (int layerIndex = 0; layerIndex < images.Length; layerIndex++) { nodes[layerIndex] = DrawImage(images[layerIndex], parent); } } return(nodes); }
public override UGUINode DrawLayer(Data.GroupNode layer, UGUINode parent) { UGUINode node = CreateRootNode(layer.displayName, layer.rect, parent); UnityEngine.UI.Toggle toggle = node.InitComponent <UnityEngine.UI.Toggle>(); if (layer.images != null) { var bgNode = DrawBackground(layer, toggle, node); DrawMask(layer, toggle, bgNode); DrawOtherLayers(layer, node); } return(node); }
/// <summary> /// 试图为Panel类型的图片添加空背景 /// </summary> /// <param name="background"></param> /// <param name="layer"></param> /// <param name="node"></param> private void TryDrawPanel(Graphic background, Data.GroupNode layer, UGUINode node) { if (background == null) { background = node.InitComponent <UnityEngine.UI.Image>(); SetRectTransform(layer.rect, background.GetComponent <RectTransform>()); Color color; if (ColorUtility.TryParseHtmlString("#FFFFFF01", out color)) { background.color = color; } background.name = layer.displayName; } }
protected void StretchTitle(UGUINode node) { var texts = node.transform.GetComponentsInChildren <Text>(); var title = Array.Find(texts, x => MatchAddress(x.name, titleAddress)); if (title) { PSDImporterUtility.SetNormalAnchor(AnchoType.XStretch | AnchoType.YStretch, node.transform as RectTransform, title.transform as RectTransform); title.rectTransform.anchoredPosition = Vector3.zero; title.alignment = TextAnchor.MiddleCenter; title.horizontalOverflow = HorizontalWrapMode.Overflow; title.verticalOverflow = VerticalWrapMode.Truncate; } }