Пример #1
0
 void HandleSpan(X3DParse.Node node, Transform canvas, CssStyle cssStyle)
 {
     CheckAttributes(node, cssStyle);
     CheckTextNode(node, canvas, cssStyle.Clone());
     foreach (X3DParse.Node child in node.Children.FindAll(x => x.NodeType == X3DParse.NodeType.Element))
     {
         HandleCommonElements(child, canvas, cssStyle.Clone());
     }
 }
Пример #2
0
        void HandleDiv(X3DParse.Node node, Transform canvas, CssStyle cssStyle)
        {
            CheckAttributes(node, cssStyle);
            GameObject panel = new GameObject("Panel");
            var        rt    = panel.AddComponent <RectTransform>();

            SetAnchorAndPivot(rt.transform);



            var cr = panel.AddComponent <CanvasRenderer>();

            Image i = panel.AddComponent <Image>();

            panel.transform.parent = canvas;
            ApplyCssStyle(panel, cssStyle);
            CheckTextNode(node, rt, cssStyle.Clone());
            foreach (X3DParse.Node child in node.Children.FindAll(x => x.NodeType == X3DParse.NodeType.Element))
            {
                HandleCommonElements(child, rt, cssStyle.Clone());
            }
        }
Пример #3
0
        void HandleCommonElements(X3DParse.Node node, Transform canvas, CssStyle cssStyle)
        {
            string name = node.Name.ToLower();

            // var a = 1;
            switch (name)
            {
            case "div":
                HandleDiv(node, canvas, cssStyle.Clone());
                break;

            case "span":
                HandleSpan(node, canvas, cssStyle.Clone());
                break;

            case "img":
                HandleImg(node, canvas, cssStyle.Clone());
                break;

            case "a":
                HandleAnchor(node, canvas, cssStyle.Clone());
                break;
            }
        }
Пример #4
0
        void HandleBody(X3DParse.Node node, Transform parent)
        {
            //add canvas
            GameObject g = new GameObject("Canvas");

            g.transform.parent = parent;
            var canvas = g.AddComponent <Canvas>();

            canvas.renderMode = RenderMode.WorldSpace;
            SetAnchorAndPivot(canvas.transform);
            CanvasScaler cs = g.AddComponent <CanvasScaler>();

            cs.scaleFactor          = 1.0f;
            cs.dynamicPixelsPerUnit = 10f;
            CssStyle cssStyle = new CssStyle();

            foreach (X3DParse.Node child in node.Children.FindAll(x => x.NodeType == X3DParse.NodeType.Element))
            {
                HandleCommonElements(child, g.transform, cssStyle.Clone());
            }
        }