Beispiel #1
0
        private static GameObject _BuildUguiGameObjectTree(UiTreeRoot uiTree)
        {
            var        uguiVisitor    = new BuildUguiGameObjectVisitor(default(Rect), null, uiTree.HorizontalPixelPerInch);
            GameObject rootGameObject = uguiVisitor.Visit(uiTree);

            return(rootGameObject);
        }
        public GameObject Visit(UiTreeRoot root)
        {
            var uiRootGameObject    = new GameObject(root.Name);
            var uiRootRectTransform = uiRootGameObject.AddComponent <RectTransform>();
            var fullDocumentRect    = new Rect(0, 0, root.Width, root.Height);

            _SetRectTransform
            (
                uiRootRectTransform,
                fullDocumentRect, fullDocumentRect,
                root.GetAnchorMinValue(), root.GetAnchorMaxValue(),
                root.Pivot
            );
            uiRootRectTransform.ForceUpdateRectTransforms();

            var layerIdTag = uiRootGameObject.AddComponent <PsdLayerIdTag>();

            layerIdTag.LayerId = -1;

            var childrenVisitor = new BuildUguiGameObjectVisitor(fullDocumentRect, uiRootRectTransform, _basePixelPerInch);

            root.Children.ForEach(child => child.Accept(childrenVisitor));

            return(uiRootGameObject);
        }
        public void Visit(GroupNode node)
        {
            if (node.IsSkipped)
            {
                return;
            }

            var groupGameObject    = new GameObject(node.Name);
            var groupRectTransform = groupGameObject.AddComponent <RectTransform>();


            var layerIdTag = groupGameObject.AddComponent <PsdLayerIdTag>();

            layerIdTag.LayerId = node.Id;

            _SetRectTransform
            (
                groupRectTransform,
                node.Rect, _parentRect,
                node.GetAnchorMinValue(), node.GetAnchorMaxValue(),
                node.Pivot
            );

            var childrenVisitor = new BuildUguiGameObjectVisitor(node.Rect, groupRectTransform, _basePixelPerInch);

            node.Children.ForEach(child => child.Accept(childrenVisitor));

            groupRectTransform.SetParent(_parent, worldPositionStays: false);
            groupGameObject.SetActive(node.IsVisible);
        }
        public GameObject Visit(UiTreeRoot root)
        {
            var uiRootGameObject = new GameObject(root.Name);

            var uiRootRectTransform = uiRootGameObject.AddComponent <RectTransform>();

            uiRootRectTransform.anchorMin = Vector2.zero;
            uiRootRectTransform.anchorMax = Vector2.one;
            uiRootRectTransform.offsetMin = Vector2.zero;
            uiRootRectTransform.offsetMax = Vector2.zero;
            uiRootRectTransform.ForceUpdateRectTransforms();

            var layerIdTag = uiRootGameObject.AddComponent <PsdLayerIdTag>();

            layerIdTag.LayerId = -1;

            var baseRect        = new Rect(0, 0, root.Width, root.Height);
            var childrenVisitor = new BuildUguiGameObjectVisitor(baseRect, uiRootRectTransform, _basePixelPerInch);

            root.Children.ForEach(child => child.Accept(childrenVisitor));

            return(uiRootGameObject);
        }