예제 #1
0
        public UGUINode DrawLayer(GroupNode layer, UGUINode parent)
        {
            UGUINode node = PSDImportUtility.InstantiateItem(GroupType.GRID, layer.Name, parent);

            node.anchoType = AnchoType.Up | AnchoType.Left;
            GridLayoutGroup gridLayoutGroup = node.InitComponent <GridLayoutGroup>();

            PSDImportUtility.SetRectTransform(layer, gridLayoutGroup.GetComponent <RectTransform>());

            gridLayoutGroup.padding  = new RectOffset(1, 1, 1, 1);
            gridLayoutGroup.cellSize = new Vector2(layer.rect.width, layer.rect.height);

            switch (layer.direction)
            {
            case Direction.Horizontal:
                gridLayoutGroup.constraint = GridLayoutGroup.Constraint.FixedColumnCount;
                break;

            case Direction.Vertical:
                gridLayoutGroup.constraint = GridLayoutGroup.Constraint.FixedRowCount;
                break;

            default:
                gridLayoutGroup.constraint = GridLayoutGroup.Constraint.Flexible;
                break;
            }
            gridLayoutGroup.constraintCount = layer.constraintCount;

            ctrl.DrawImages(layer.images.ToArray(), node);
            ctrl.DrawLayers(layer.groups.ToArray() as GroupNode[], node);
            return(node);
        }
예제 #2
0
        public UGUINode DrawLayer(GroupNode layer, UGUINode parent)
        {
            UGUINode node = PSDImportUtility.InstantiateItem(GroupType.GROUP, layer.Name, parent);

            UnityEngine.UI.LayoutGroup group = null;
            switch (layer.direction)
            {
            case Direction.Horizontal:
                group = node.InitComponent <UnityEngine.UI.HorizontalLayoutGroup>();
                group.childAlignment = TextAnchor.UpperLeft;
                break;

            case Direction.Vertical:
                group = node.InitComponent <UnityEngine.UI.VerticalLayoutGroup>();
                group.childAlignment = TextAnchor.UpperLeft;
                break;

            default:
                break;
            }
            ((UnityEngine.UI.VerticalLayoutGroup)group).spacing = layer.spacing;

            PSDImportUtility.SetRectTransform(layer, group.GetComponent <RectTransform>());

            UGUINode[] nodes = pSDImportCtrl.DrawImages(layer.images.ToArray(), node);
            foreach (var item in nodes)
            {
                item.anchoType = AnchoType.Left | AnchoType.Up;
            }
            nodes = pSDImportCtrl.DrawLayers(layer.groups.ToArray(), node);
            foreach (var item in nodes)
            {
                item.anchoType = AnchoType.Left | AnchoType.Up;
            }
            return(node);
        }