当前位置: 首页>>代码示例>>C#>>正文


C# XML.GetAttributeArray方法代码示例

本文整理汇总了C#中FairyGUI.Utils.XML.GetAttributeArray方法的典型用法代码示例。如果您正苦于以下问题:C# XML.GetAttributeArray方法的具体用法?C# XML.GetAttributeArray怎么用?C# XML.GetAttributeArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FairyGUI.Utils.XML的用法示例。


在下文中一共展示了XML.GetAttributeArray方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Setup_BeforeAdd

        public virtual void Setup_BeforeAdd(XML xml)
        {
            string str;
            string[] arr;

            id = xml.GetAttribute("id");
            name = xml.GetAttribute("name");

            arr = xml.GetAttributeArray("xy");
            if (arr != null)
                this.SetXY(int.Parse(arr[0]), int.Parse(arr[1]));

            arr = xml.GetAttributeArray("size");
            if (arr != null)
            {
                initWidth = int.Parse(arr[0]);
                initHeight = int.Parse(arr[1]);
                SetSize(initWidth, initHeight, true);
            }

            arr = xml.GetAttributeArray("scale");
            if (arr != null)
                SetScale(float.Parse(arr[0]), float.Parse(arr[1]));

            arr = xml.GetAttributeArray("skew");
            if (arr != null)
                this.skew = new Vector2(float.Parse(arr[0]), float.Parse(arr[1]));

            str = xml.GetAttribute("rotation");
            if (str != null)
                this.rotation = int.Parse(str);

            arr = xml.GetAttributeArray("pivot");
            if (arr != null)
            {
                float f1 = float.Parse(arr[0]);
                float f2 = float.Parse(arr[1]);
                //处理旧版本的兼容性(旧版本发布的值是坐标值,新版本是比例,一般都小于2)
                if (f1 > 2)
                {
                    if (sourceWidth != 0)
                        f1 = f1 / sourceWidth;
                    else
                        f1 = 0;
                }
                if (f2 > 2)
                {
                    if (sourceHeight != 0)
                        f2 = f2 / sourceHeight;
                    else
                        f2 = 0;
                }
                this.SetPivot(f1, f2, xml.GetAttributeBool("anchor"));
            }
            else
                this.SetPivot(0, 0, false);

            str = xml.GetAttribute("alpha");
            if (str != null)
                this.alpha = float.Parse(str);

            this.touchable = xml.GetAttributeBool("touchable", true);
            this.visible = xml.GetAttributeBool("visible", true);
            this.grayed = xml.GetAttributeBool("grayed", false);

            str = xml.GetAttribute("blend");
            if (str != null)
                this.blendMode = FieldTypes.ParseBlendMode(str);

            str = xml.GetAttribute("filter");
            if (str != null)
            {
                switch (str)
                {
                    case "color":
                        ColorFilter cf = new ColorFilter();
                        this.filter = cf;
                        arr = xml.GetAttributeArray("filterData");
                        cf.AdjustBrightness(float.Parse(arr[0]));
                        cf.AdjustContrast(float.Parse(arr[1]));
                        cf.AdjustSaturation(float.Parse(arr[2]));
                        cf.AdjustHue(float.Parse(arr[3]));
                        break;
                }
            }

            str = xml.GetAttribute("tooltips");
            if (str != null)
                this.tooltips = str;
        }
开发者ID:fairygui,项目名称:FairyGUI-unity,代码行数:90,代码来源:GObject.cs

示例2: ConstructFromXML

        public virtual void ConstructFromXML(XML xml)
        {
            string str;
            string[] arr;

            underConstruct = true;

            arr = xml.GetAttributeArray("size");
            sourceWidth = int.Parse(arr[0]);
            sourceHeight = int.Parse(arr[1]);
            initWidth = sourceWidth;
            initHeight = sourceHeight;

            OverflowType overflow;
            str = xml.GetAttribute("overflow");
            if (str != null)
                overflow = FieldTypes.ParseOverflowType(str);
            else
                overflow = OverflowType.Visible;

            ScrollType scroll;
            str = xml.GetAttribute("scroll");
            if (str != null)
                scroll = FieldTypes.ParseScrollType(str);
            else
                scroll = ScrollType.Vertical;

            ScrollBarDisplayType scrollBarDisplay;
            str = xml.GetAttribute("scrollBar");
            if (str != null)
                scrollBarDisplay = FieldTypes.ParseScrollBarDisplayType(str);
            else
                scrollBarDisplay = ScrollBarDisplayType.Default;

            int scrollBarFlags = xml.GetAttributeInt("scrollBarFlags");

            Margin scrollBarMargin = new Margin();
            str = xml.GetAttribute("scrollBarMargin");
            if (str != null)
                scrollBarMargin.Parse(str);

            str = xml.GetAttribute("margin");
            if (str != null)
                _margin.Parse(str);

            SetSize(sourceWidth, sourceHeight);

            SetupOverflowAndScroll(overflow, scrollBarMargin, scroll, scrollBarDisplay, scrollBarFlags);

            arr = xml.GetAttributeArray("clipSoftness");
            if (arr != null)
                this.clipSoftness = new Vector2(int.Parse(arr[0]), int.Parse(arr[1]));

            _buildingDisplayList = true;

            XMLList col = xml.Elements("controller");
            Controller controller;
            foreach (XML cxml in col)
            {
                controller = new Controller();
                _controllers.Add(controller);
                controller.parent = this;
                controller.Setup(cxml);
            }

            XML listNode = xml.GetNode("displayList");
            if (listNode != null)
            {
                col = listNode.Elements();
                GObject u;
                foreach (XML cxml in col)
                {
                    u = ConstructChild(cxml);
                    if (u == null)
                        continue;

                    u.underConstruct = true;
                    u.constructingData = cxml;
                    u.Setup_BeforeAdd(cxml);
                    AddChild(u);
                }
            }
            this.relations.Setup(xml);

            int cnt = _children.Count;
            for (int i = 0; i < cnt; i++)
            {
                GObject u = _children[i];
                u.relations.Setup(u.constructingData);
            }

            for (int i = 0; i < cnt; i++)
            {
                GObject u = _children[i];
                u.Setup_AfterAdd(u.constructingData);
                u.underConstruct = false;
                u.constructingData = null;
            }

            XMLList transCol = xml.Elements("transition");
//.........这里部分代码省略.........
开发者ID:hxyxj,项目名称:FairyGUI-unity,代码行数:101,代码来源:GComponent.cs

示例3: LoadMovieClip

        void LoadMovieClip(PackageItem item)
        {
            string str = GetDesc(item.id + ".xml");
            XML xml = new XML(str);
            string[] arr = null;

            arr = xml.GetAttributeArray("pivot");
            if (arr != null)
            {
                item.pivot.x = int.Parse(arr[0]);
                item.pivot.y = int.Parse(arr[1]);
            }
            str = xml.GetAttribute("interval");
            if (str != null)
                item.interval = float.Parse(str) / 1000f;
            item.swing = xml.GetAttributeBool("swing", false);
            str = xml.GetAttribute("repeatDelay");
            if (str != null)
                item.repeatDelay = float.Parse(str) / 1000f;
            int frameCount = xml.GetAttributeInt("frameCount");
            item.frames = new Frame[frameCount];

            XMLList frameNodes = xml.GetNode("frames").Elements();

            int i = 0;
            foreach (XML frameNode in frameNodes)
            {
                Frame frame = new Frame();
                arr = frameNode.GetAttributeArray("rect");
                frame.rect = new Rect(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), int.Parse(arr[3]));
                str = frameNode.GetAttribute("addDelay");
                if (str != null)
                    frame.addDelay = float.Parse(str) / 1000f;

                AtlasSprite sprite;
                if (_sprites.TryGetValue(item.id + "_" + i, out sprite))
                    frame.texture = CreateSpriteTexture(sprite);
                item.frames[i] = frame;
                i++;
            }
        }
开发者ID:aideas,项目名称:F-N-GUI,代码行数:41,代码来源:UIPackage.cs

示例4: Setup_BeforeAdd

        public override void Setup_BeforeAdd(XML xml)
        {
            base.Setup_BeforeAdd(xml);

            string str;
            string[] arr;

            str = xml.GetAttribute("layout");
            if (str != null)
                _layout = FieldTypes.ParseListLayoutType(str);
            else
                _layout = ListLayoutType.SingleColumn;

            str = xml.GetAttribute("selectionMode");
            if (str != null)
                selectionMode = FieldTypes.ParseListSelectionMode(str);
            else
                selectionMode = ListSelectionMode.Single;

            OverflowType overflow;
            str = xml.GetAttribute("overflow");
            if (str != null)
                overflow = FieldTypes.ParseOverflowType(str);
            else
                overflow = OverflowType.Visible;

            str = xml.GetAttribute("margin");
            if (str != null)
                _margin.Parse(str);

            str = xml.GetAttribute("align");
            if (str != null)
                _align = FieldTypes.ParseAlign(str);

            str = xml.GetAttribute("vAlign");
            if (str != null)
                _verticalAlign = FieldTypes.ParseVerticalAlign(str);

            if (overflow == OverflowType.Scroll)
            {
                ScrollType scroll;
                str = xml.GetAttribute("scroll");
                if (str != null)
                    scroll = FieldTypes.ParseScrollType(str);
                else
                    scroll = ScrollType.Vertical;

                ScrollBarDisplayType scrollBarDisplay;
                str = xml.GetAttribute("scrollBar");
                if (str != null)
                    scrollBarDisplay = FieldTypes.ParseScrollBarDisplayType(str);
                else
                    scrollBarDisplay = ScrollBarDisplayType.Default;

                int scrollBarFlags = xml.GetAttributeInt("scrollBarFlags");

                Margin scrollBarMargin = new Margin();
                str = xml.GetAttribute("scrollBarMargin");
                if (str != null)
                    scrollBarMargin.Parse(str);

                string vtScrollBarRes = null;
                string hzScrollBarRes = null;
                arr = xml.GetAttributeArray("scrollBarRes");
                if (arr != null)
                {
                    vtScrollBarRes = arr[0];
                    hzScrollBarRes = arr[1];
                }

                SetupScroll(scrollBarMargin, scroll, scrollBarDisplay, scrollBarFlags, vtScrollBarRes, hzScrollBarRes);
            }
            else
            {
                SetupOverflow(overflow);
            }

            arr = xml.GetAttributeArray("clipSoftness");
            if (arr != null)
                this.clipSoftness = new Vector2(int.Parse(arr[0]), int.Parse(arr[1]));

            _lineGap = xml.GetAttributeInt("lineGap");
            _columnGap = xml.GetAttributeInt("colGap");
            _lineItemCount = xml.GetAttributeInt("lineItemCount");
            defaultItem = xml.GetAttribute("defaultItem");

            autoResizeItem = xml.GetAttributeBool("autoItemSize", true);

            XMLList.Enumerator et = xml.GetEnumerator("item");
            while (et.MoveNext())
            {
                XML ix = et.Current;
                string url = ix.GetAttribute("url");
                if (string.IsNullOrEmpty(url))
                {
                    url = defaultItem;
                    if (string.IsNullOrEmpty(url))
                        continue;
                }

//.........这里部分代码省略.........
开发者ID:fairygui,项目名称:FairyGUI-unity,代码行数:101,代码来源:GList.cs

示例5: Setup

        public void Setup(XML xml)
        {
            string str;

            _controller = _owner.parent.GetController(xml.GetAttribute("controller"));
            if (_controller == null)
                return;

            Init();

            str = xml.GetAttribute("tween");
            if (str != null)
                tween = true;

            str = xml.GetAttribute("ease");
            if (str != null)
                easeType = FieldTypes.ParseEaseType(str);

            str = xml.GetAttribute("duration");
            if (str != null)
                tweenTime = float.Parse(str);

            str = xml.GetAttribute("delay");
            if (str != null)
                delay = float.Parse(str);

            if (this is GearDisplay)
            {
                string[] pages = xml.GetAttributeArray("pages");
                if (pages != null)
                    ((GearDisplay)this).pages = pages;
            }
            else
            {
                string[] pages = xml.GetAttributeArray("pages");
                string[] values = xml.GetAttributeArray("values", '|');

                if (pages != null && values != null)
                {
                    for (int i = 0; i < values.Length; i++)
                        AddStatus(pages[i], values[i]);
                }
                str = xml.GetAttribute("default");
                if (str != null)
                    AddStatus(null, str);
            }
        }
开发者ID:fairygui,项目名称:FairyGUI-unity,代码行数:47,代码来源:GearBase.cs

示例6: Setup_BeforeAdd

        public override void Setup_BeforeAdd(XML xml)
        {
            base.Setup_BeforeAdd(xml);

            string str;
            str = xml.GetAttribute("layout");
            if (str != null)
                _layout = FieldTypes.ParseListLayoutType(str);
            else
                _layout = ListLayoutType.SingleColumn;

            str = xml.GetAttribute("selectionMode");
            if (str != null)
                selectionMode = FieldTypes.ParseListSelectionMode(str);
            else
                selectionMode = ListSelectionMode.Single;

            OverflowType overflow;
            str = xml.GetAttribute("overflow");
            if (str != null)
                overflow = FieldTypes.ParseOverflowType(str);
            else
                overflow = OverflowType.Visible;

            ScrollType scroll;
            str = xml.GetAttribute("scroll");
            if (str != null)
                scroll = FieldTypes.ParseScrollType(str);
            else
                scroll = ScrollType.Vertical;

            ScrollBarDisplayType scrollBarDisplay;
            str = xml.GetAttribute("scrollBar");
            if (str != null)
                scrollBarDisplay = FieldTypes.ParseScrollBarDisplayType(str);
            else
                scrollBarDisplay = ScrollBarDisplayType.Default;

            int scrollBarFlags = xml.GetAttributeInt("scrollBarFlags");

            Margin scrollBarMargin = new Margin();
            str = xml.GetAttribute("scrollBarMargin");
            if (str != null)
                scrollBarMargin.Parse(str);

            str = xml.GetAttribute("margin");
            if (str != null)
                _margin.Parse(str);

            SetupOverflowAndScroll(overflow, scrollBarMargin, scroll, scrollBarDisplay, scrollBarFlags);

            string[] arr = xml.GetAttributeArray("clipSoftness");
            if (arr != null)
                this.clipSoftness = new Vector2(int.Parse(arr[0]), int.Parse(arr[1]));

            _lineGap = xml.GetAttributeInt("lineGap");
            _columnGap = xml.GetAttributeInt("colGap");
            defaultItem = xml.GetAttribute("defaultItem");

            autoResizeItem = xml.GetAttributeBool("autoItemSize", true);

            XMLList col = xml.Elements("item");
            foreach (XML ix in col)
            {
                string url = ix.GetAttribute("url");
                if (string.IsNullOrEmpty(url))
                    url = defaultItem;
                if (string.IsNullOrEmpty(url))
                    continue;

                GObject obj = AddItemFromPool(url);
                if (obj is GButton)
                {
                    ((GButton)obj).title = ix.GetAttribute("title");
                    ((GButton)obj).icon = ix.GetAttribute("icon");
                }
                else if (obj is GLabel)
                {
                    ((GLabel)obj).title = ix.GetAttribute("title");
                    ((GLabel)obj).icon = ix.GetAttribute("icon");
                }
            }
        }
开发者ID:niuniuzhu,项目名称:FairyGUI-unity,代码行数:83,代码来源:GList.cs

示例7: ConstructFromXML

        public virtual void ConstructFromXML(XML xml)
        {
            string str;
            string[] arr;

            underConstruct = true;

            arr = xml.GetAttributeArray("size");
            sourceWidth = int.Parse(arr[0]);
            sourceHeight = int.Parse(arr[1]);
            initWidth = sourceWidth;
            initHeight = sourceHeight;

            SetSize(sourceWidth, sourceHeight);

            arr = xml.GetAttributeArray("pivot");
            if (arr != null)
            {
                float f1 = float.Parse(arr[0]);
                float f2 = float.Parse(arr[1]);
                this.SetPivot(f1, f2, xml.GetAttributeBool("anchor"));
            }

            this.opaque = xml.GetAttributeBool("opaque", true);
            arr = xml.GetAttributeArray("hitTest");
            if (arr != null)
            {
                PixelHitTestData hitTestData = _packageItem.owner.GetPixelHitTestData(arr[0]);
                if (hitTestData != null)
                    this.rootContainer.hitArea = new PixelHitTest(hitTestData, int.Parse(arr[1]), int.Parse(arr[2]));
            }

            OverflowType overflow;
            str = xml.GetAttribute("overflow");
            if (str != null)
                overflow = FieldTypes.ParseOverflowType(str);
            else
                overflow = OverflowType.Visible;

            str = xml.GetAttribute("margin");
            if (str != null)
                _margin.Parse(str);

            if (overflow == OverflowType.Scroll)
            {
                ScrollType scroll;
                str = xml.GetAttribute("scroll");
                if (str != null)
                    scroll = FieldTypes.ParseScrollType(str);
                else
                    scroll = ScrollType.Vertical;

                ScrollBarDisplayType scrollBarDisplay;
                str = xml.GetAttribute("scrollBar");
                if (str != null)
                    scrollBarDisplay = FieldTypes.ParseScrollBarDisplayType(str);
                else
                    scrollBarDisplay = ScrollBarDisplayType.Default;

                int scrollBarFlags = xml.GetAttributeInt("scrollBarFlags");

                Margin scrollBarMargin = new Margin();
                str = xml.GetAttribute("scrollBarMargin");
                if (str != null)
                    scrollBarMargin.Parse(str);

                string vtScrollBarRes = null;
                string hzScrollBarRes = null;
                arr = xml.GetAttributeArray("scrollBarRes");
                if (arr != null)
                {
                    vtScrollBarRes = arr[0];
                    hzScrollBarRes = arr[1];
                }

                SetupScroll(scrollBarMargin, scroll, scrollBarDisplay, scrollBarFlags, vtScrollBarRes, hzScrollBarRes);
            }
            else
                SetupOverflow(overflow);

            arr = xml.GetAttributeArray("clipSoftness");
            if (arr != null)
                this.clipSoftness = new Vector2(int.Parse(arr[0]), int.Parse(arr[1]));

            _buildingDisplayList = true;

            XMLList col = xml.Elements("controller");
            Controller controller;
            foreach (XML cxml in col)
            {
                controller = new Controller();
                _controllers.Add(controller);
                controller.parent = this;
                controller.Setup(cxml);
            }

            XML listNode = xml.GetNode("displayList");
            if (listNode != null)
            {
                col = listNode.Elements();
//.........这里部分代码省略.........
开发者ID:kensong1194717296,项目名称:FairyGUI-unity,代码行数:101,代码来源:GComponent.cs

示例8: Setup

        public void Setup(XML xml)
        {
            string[] arr;

            name = xml.GetAttribute("name");
            autoRadioGroupDepth = xml.GetAttributeBool("autoRadioGroupDepth");

            arr = xml.GetAttributeArray("pages");
            if (arr != null)
            {
                int cnt = arr.Length;
                for (int i = 0; i < cnt; i += 2)
                {
                    _pageIds.Add(arr[i]);
                    _pageNames.Add(arr[i + 1]);
                }
            }

            arr = xml.GetAttributeArray("transitions");
            if (arr != null)
            {
                _pageTransitions = new List<PageTransition>();

                int cnt = arr.Length;
                for (int i = 0; i < cnt; i++)
                {
                    string str = arr[i];

                    PageTransition pt = new PageTransition();
                    int k = str.IndexOf("=");
                    pt.transitionName = str.Substring(k + 1);
                    str = str.Substring(0, k);
                    k = str.IndexOf("-");
                    pt.toIndex = int.Parse(str.Substring(k + 1));
                    str = str.Substring(0, k);
                    if (str == "*")
                        pt.fromIndex = -1;
                    else
                        pt.fromIndex = int.Parse(str);
                    _pageTransitions.Add(pt);
                }
            }

            if (parent != null && _pageIds.Count >= 0)
                _selectedIndex = 0;
            else
                _selectedIndex = -1;
        }
开发者ID:yinlei,项目名称:Fishing,代码行数:48,代码来源:Controller.cs

示例9: Setup_BeforeAdd

        public virtual void Setup_BeforeAdd(XML xml)
        {
            string str;
            string[] arr;

            id = xml.GetAttribute("id");
            name = xml.GetAttribute("name");

            arr = xml.GetAttributeArray("xy");
            if (arr != null)
                this.SetXY(int.Parse(arr[0]), int.Parse(arr[1]));

            arr = xml.GetAttributeArray("size");
            if (arr != null)
            {
                initWidth = int.Parse(arr[0]);
                initHeight = int.Parse(arr[1]);
                SetSize(initWidth, initHeight);
            }

            arr = xml.GetAttributeArray("scale");
            if (arr != null)
                SetScale(float.Parse(arr[0]), float.Parse(arr[1]));

            str = xml.GetAttribute("rotation");
            if (str != null)
                this.rotation = int.Parse(str);

            arr = xml.GetAttributeArray("pivot");
            if (arr != null)
                this.SetPivot(int.Parse(arr[0]), int.Parse(arr[1]));

            str = xml.GetAttribute("alpha");
            if (str != null)
                this.alpha = float.Parse(str);

            this.touchable = xml.GetAttributeBool("touchable", true);
            this.visible = xml.GetAttributeBool("visible", true);
            this.grayed = xml.GetAttributeBool("grayed", false);
            str = xml.GetAttribute("tooltips");
            if (str != null)
                this.tooltips = str;
        }
开发者ID:niuniuzhu,项目名称:FairyGUI-unity,代码行数:43,代码来源:GObject.cs

示例10: Setup

        public void Setup(XML xml)
        {
            string str;

            _controller = _owner.parent.GetController(xml.GetAttribute("controller"));
            if (_controller == null)
                return;

            Init();

            string[] pages = xml.GetAttributeArray("pages");
            if (pages != null)
            {
                foreach (string s in pages)
                    pageSet.AddById(s);
            }

            str = xml.GetAttribute("tween");
            if (str != null)
                tween = true;

            str = xml.GetAttribute("ease");
            if (str != null)
                easeType = FieldTypes.ParseEaseType(str);

            str = xml.GetAttribute("duration");
            if (str != null)
                tweenTime = float.Parse(str);

            str = xml.GetAttribute("values");
            string[] values = null;
            if (str != null)
                values = str.Split(jointChar1);

            if (values != null)
            {
                for (int i = 0; i < values.Length; i++)
                {
                    str = values[i];
                    if (str != "-")
                        AddStatus(pages[i], str);
                }
            }
            str = xml.GetAttribute("default");
            if (str != null)
                AddStatus(null, str);
        }
开发者ID:hxyxj,项目名称:FairyGUI-unity,代码行数:47,代码来源:GearBase.cs


注:本文中的FairyGUI.Utils.XML.GetAttributeArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。