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


C# XML.GetAttribute方法代码示例

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


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

示例1: 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

示例2: Setup_BeforeAdd

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

            string str;
            str = xml.GetAttribute("url");
            if (str != null)
                _url = str;

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

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

            str = xml.GetAttribute("fill");
            if (str != null)
                _fill = FieldTypes.ParseFillType(str);

            _autoSize = xml.GetAttributeBool("autoSize", false);

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

            _playing = xml.GetAttributeBool("playing", true);

            str = xml.GetAttribute("color");
            if (str != null)
                this.color = ToolSet.ConvertFromHtmlColor(str);

            str = xml.GetAttribute("fillMethod");
            if (str != null)
                _content.fillMethod = FieldTypes.ParseFillMethod(str);

            if (_content.fillMethod != FillMethod.None)
            {
                _content.fillOrigin = xml.GetAttributeInt("fillOrigin");
                _content.fillClockwise = xml.GetAttributeBool("fillClockwise", true);
                _content.fillAmount = (float)xml.GetAttributeInt("fillAmount", 100) / 100;
            }

            if (_url != null)
                LoadContent();
        }
开发者ID:kensong1194717296,项目名称:FairyGUI-unity,代码行数:47,代码来源:GLoader.cs

示例3: Setup_BeforeAdd

        public override void Setup_BeforeAdd(XML xml)
        {
            string str;
            string type = xml.GetAttribute("type");
            if (type != null && type != "empty")
            {
                _shape = new Shape();
                _shape.gOwner = this;
                displayObject = _shape;
            }

            base.Setup_BeforeAdd(xml);

            if (_shape != null)
            {
                int lineSize;
                str = xml.GetAttribute("lineSize");
                if (str != null)
                    lineSize = int.Parse(str);
                else
                    lineSize = 1;

                Color lineColor;
                str = xml.GetAttribute("lineColor");
                if (str != null)
                    lineColor = ToolSet.ConvertFromHtmlColor(str);
                else
                    lineColor = Color.black;

                Color fillColor;
                str = xml.GetAttribute("fillColor");
                if (str != null)
                    fillColor = ToolSet.ConvertFromHtmlColor(str);
                else
                    fillColor = Color.white;

                if (type == "rect")
                    DrawRect(this.width, this.height, lineSize, lineColor, fillColor);
                else
                    DrawEllipse(this.width, this.height, fillColor);
            }
        }
开发者ID:fairygui,项目名称:FairyGUI-unity,代码行数:42,代码来源:GGraph.cs

示例4: Setup

        public void Setup(XML xml)
        {
            this.name = xml.GetAttribute("name");
            _options = xml.GetAttributeInt("options");
            this.autoPlay = xml.GetAttributeBool("autoPlay");
            if (this.autoPlay)
            {
                this.autoPlayRepeat = xml.GetAttributeInt("autoPlayRepeat", 1);
                this.autoPlayDelay = xml.GetAttributeFloat("autoPlayDelay");
            }
            XMLList col = xml.Elements("item");

            foreach (XML cxml in col)
            {
                TransitionItem item = new TransitionItem();
                _items.Add(item);

                item.time = (float)cxml.GetAttributeInt("time") / (float)FRAME_RATE;
                item.targetId = cxml.GetAttribute("target", string.Empty);
                item.type = FieldTypes.ParseTransitionActionType(cxml.GetAttribute("type"));
                item.tween = cxml.GetAttributeBool("tween");
                item.label = cxml.GetAttribute("label");
                if (item.tween)
                {
                    item.duration = (float)cxml.GetAttributeInt("duration") / FRAME_RATE;
                    if (item.time + item.duration > _maxTime)
                        _maxTime = item.time + item.duration;

                    string ease = cxml.GetAttribute("ease");
                    if (ease != null)
                        item.easeType = FieldTypes.ParseEaseType(ease);

                    item.repeat = cxml.GetAttributeInt("repeat");
                    item.yoyo = cxml.GetAttributeBool("yoyo");
                    item.label2 = cxml.GetAttribute("label2");

                    string v = cxml.GetAttribute("endValue");
                    if (v != null)
                    {
                        DecodeValue(item.type, cxml.GetAttribute("startValue", string.Empty), item.startValue);
                        DecodeValue(item.type, v, item.endValue);
                    }
                    else
                    {
                        item.tween = false;
                        DecodeValue(item.type, cxml.GetAttribute("startValue", string.Empty), item.value);
                    }
                }
                else
                {
                    if (item.time > _maxTime)
                        _maxTime = item.time;
                    DecodeValue(item.type, cxml.GetAttribute("value", string.Empty), item.value);
                }
            }
        }
开发者ID:yinlei,项目名称:Fishing,代码行数:56,代码来源:Transition.cs

示例5: LoadPackage

        void LoadPackage()
        {
            string[] arr = null;
            string str;

            str = LoadString("sprites.bytes");
            if (str == null)
            {
                Debug.LogError("FairyGUI: cannot load package from " + _assetNamePrefix);
                return;
            }
            arr = str.Split(sep1);
            int cnt = arr.Length;
            for (int i = 1; i < cnt; i++)
            {
                str = arr[i];
                if (str.Length == 0)
                    continue;

                string[] arr2 = str.Split(sep2);
                AtlasSprite sprite = new AtlasSprite();
                string itemId = arr2[0];
                int binIndex = int.Parse(arr2[1]);
                if (binIndex >= 0)
                    sprite.atlas = "atlas" + binIndex;
                else
                {
                    int pos = itemId.IndexOf("_");
                    if (pos == -1)
                        sprite.atlas = "atlas_" + itemId;
                    else
                        sprite.atlas = "atlas_" + itemId.Substring(0, pos);
                }
                sprite.rect.x = int.Parse(arr2[2]);
                sprite.rect.y = int.Parse(arr2[3]);
                sprite.rect.width = int.Parse(arr2[4]);
                sprite.rect.height = int.Parse(arr2[5]);
                sprite.rotated = arr2[6] == "1";
                _sprites[itemId] = sprite;
            }

            byte[] hittestData = LoadBinary("hittest.bytes");
            if (hittestData != null)
            {
                ByteBuffer ba = new ByteBuffer(hittestData);
                while (ba.bytesAvailable)
                {
                    PixelHitTestData pht = new PixelHitTestData();
                    _hitTestDatas[ba.ReadString()] = pht;
                    pht.Load(ba);
                }
            }

            str = _descPack["package.xml"];
            XML xml = new XML(str);

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

            XML rxml = xml.GetNode("resources");
            if (rxml == null)
                throw new Exception("Invalid package xml");

            XMLList resources = rxml.Elements();

            _itemsById = new Dictionary<string, PackageItem>();
            _itemsByName = new Dictionary<string, PackageItem>();
            PackageItem pi;

            foreach (XML cxml in resources)
            {
                pi = new PackageItem();
                pi.owner = this;
                pi.type = FieldTypes.ParsePackageItemType(cxml.name);
                pi.id = cxml.GetAttribute("id");
                pi.name = cxml.GetAttribute("name");
                pi.exported = cxml.GetAttributeBool("exported");
                pi.file = cxml.GetAttribute("file");
                str = cxml.GetAttribute("size");
                if (str != null)
                {
                    arr = str.Split(sep0);
                    pi.width = int.Parse(arr[0]);
                    pi.height = int.Parse(arr[1]);
                }
                switch (pi.type)
                {
                    case PackageItemType.Image:
                        {
                            string scale = cxml.GetAttribute("scale");
                            if (scale == "9grid")
                            {
                                arr = cxml.GetAttributeArray("scale9grid");
                                if (arr != null)
                                {
                                    Rect rect = new Rect();
                                    rect.x = int.Parse(arr[0]);
                                    rect.y = int.Parse(arr[1]);
                                    rect.width = int.Parse(arr[2]);
                                    rect.height = int.Parse(arr[3]);
//.........这里部分代码省略.........
开发者ID:yinlei,项目名称:Fishing,代码行数:101,代码来源:UIPackage.cs

示例6: Setup_AfterAdd

        public virtual void Setup_AfterAdd(XML xml)
        {
            string str;

            str = xml.GetAttribute("group");
            if (str != null)
                group = parent.GetChildById(str) as GGroup;

            XMLList.Enumerator et = xml.GetEnumerator();
            XML cxml;
            int index;
            while (et.MoveNext())
            {
                cxml = et.Current;
                if (GearXMLKeys.TryGetValue(cxml.name, out index))
                    GetGear(index).Setup(cxml);
            }
        }
开发者ID:fairygui,项目名称:FairyGUI-unity,代码行数:18,代码来源:GObject.cs

示例7: LoadPackage

        void LoadPackage()
        {
            string[] arr = null;
            string str;

            str = LoadString("sprites.bytes");
            arr = str.Split(sep1);
            int cnt = arr.Length;
            for (int i = 1; i < cnt; i++)
            {
                str = arr[i];
                if (str.Length == 0)
                    continue;

                string[] arr2 = str.Split(sep2);
                AtlasSprite sprite = new AtlasSprite();
                string itemId = arr2[0];
                int binIndex = int.Parse(arr2[1]);
                if (binIndex >= 0)
                    sprite.atlas = "atlas" + binIndex;
                else
                {
                    int pos = itemId.IndexOf("_");
                    if (pos == -1)
                        sprite.atlas = "atlas_" + itemId;
                    else
                        sprite.atlas = "atlas_" + itemId.Substring(0, pos);
                }
                sprite.rect.x = int.Parse(arr2[2]);
                sprite.rect.y = int.Parse(arr2[3]);
                sprite.rect.width = int.Parse(arr2[4]);
                sprite.rect.height = int.Parse(arr2[5]);
                sprite.rotated = arr2[6] == "1";
                _sprites[itemId] = sprite;
            }

            str = GetDesc("package.xml");
            XML xml = new XML(str);

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

            XML rxml = xml.GetNode("resources");
            if (rxml == null)
                throw new Exception("Invalid package xml");

            XMLList resources = rxml.Elements();

            _itemsById = new Dictionary<string, PackageItem>();
            _itemsByName = new Dictionary<string, PackageItem>(); ;
            PackageItem pi;

            foreach (XML cxml in resources)
            {
                pi = new PackageItem();
                pi.type = FieldTypes.ParsePackageItemType(cxml.name);
                pi.id = cxml.GetAttribute("id");
                pi.name = cxml.GetAttribute("name");
                pi.file = cxml.GetAttribute("file");
                str = cxml.GetAttribute("size");
                if (str != null)
                {
                    arr = str.Split(sep0);
                    pi.width = int.Parse(arr[0]);
                    pi.height = int.Parse(arr[1]);
                }
                switch (pi.type)
                {
                    case PackageItemType.Image:
                        {
                            string scale = cxml.GetAttribute("scale");
                            if (scale == "9grid")
                            {
                                arr = cxml.GetAttributeArray("scale9grid");
                                if (arr != null)
                                {
                                    Rect rect = new Rect();
                                    rect.x = int.Parse(arr[0]);
                                    rect.y = int.Parse(arr[1]);
                                    rect.width = int.Parse(arr[2]);
                                    rect.height = int.Parse(arr[3]);
                                    pi.scale9Grid = rect;
                                }
                            }
                            else if (scale == "tile")
                                pi.scaleByTile = true;
                            break;
                        }
                }
                pi.owner = this;
                _items.Add(pi);
                _itemsById[pi.id] = pi;
                if (pi.name != null)
                    _itemsByName[pi.name] = pi;
            }

            cnt = _items.Count;
            for (int i = 0; i < cnt; i++)
            {
                pi = _items[i];
//.........这里部分代码省略.........
开发者ID:aideas,项目名称:F-N-GUI,代码行数:101,代码来源:UIPackage.cs

示例8: 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

示例9: Setup_AfterAdd

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

            XML cxml = xml.GetNode("gearColor");
            if (cxml != null)
                gearColor.Setup(cxml);

            UpdateTextFormat();

            string str = xml.GetAttribute("text");
            if (str != null && str.Length > 0)
                this.text = str;
        }
开发者ID:yinlei,项目名称:Fishing,代码行数:14,代码来源:GTextField.cs

示例10: 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

示例11: 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

示例12: Setup_AfterAdd

        public virtual void Setup_AfterAdd(XML xml)
        {
            XML cxml = null;
            string str;

            str = xml.GetAttribute("group");
            if (str != null)
                group = parent.GetChildById(str) as GGroup;

            cxml = xml.GetNode("gearDisplay");
            if (cxml != null)
                gearDisplay.Setup(cxml);

            cxml = xml.GetNode("gearXY");
            if (cxml != null)
                gearXY.Setup(cxml);

            cxml = xml.GetNode("gearSize");
            if (cxml != null)
                gearSize.Setup(cxml);

            cxml = xml.GetNode("gearLook");
            if (cxml != null)
                gearLook.Setup(cxml);
        }
开发者ID:kensong1194717296,项目名称:FairyGUI-unity,代码行数:25,代码来源:GObject.cs

示例13: 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

示例14: Setup_BeforeAdd

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

            string str;
            str = xml.GetAttribute("color");
            if (str != null)
                this.color = ToolSet.ConvertFromHtmlColor(str);

            str = xml.GetAttribute("flip");
            if (str != null)
                _content.flip = FieldTypes.ParseFlipType(str);
        }
开发者ID:niuniuzhu,项目名称:FairyGUI-unity,代码行数:13,代码来源:GImage.cs

示例15: LoadMovieClip

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

            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 MovieClip.Frame[frameCount];

            int i = 0;
            string spriteId;
            XML frameNode;
            MovieClip.Frame frame;
            AtlasSprite sprite;

            XMLList.Enumerator et = xml.GetNode("frames").GetEnumerator();
            while (et.MoveNext())
            {
                frameNode = et.Current;
                frame = new MovieClip.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;

                str = frameNode.GetAttribute("sprite");
                if (str != null)
                    spriteId = item.id + "_" + str;
                else if (frame.rect.width != 0)
                    spriteId = item.id + "_" + i;
                else
                    spriteId = null;

                if (spriteId != null && _sprites.TryGetValue(spriteId, out sprite))
                {
                    PackageItem atlasItem = _itemsById[sprite.atlas];
                    if (atlasItem != null)
                    {
                        if (item.texture == null)
                            item.texture = (NTexture)GetItemAsset(atlasItem);
                        frame.uvRect = new Rect(sprite.rect.x / item.texture.width * item.texture.uvRect.width,
                            1 - sprite.rect.yMax * item.texture.uvRect.height / item.texture.height,
                            sprite.rect.width * item.texture.uvRect.width / item.texture.width,
                            sprite.rect.height * item.texture.uvRect.height / item.texture.height);
                    }
                }
                item.frames[i] = frame;
                i++;
            }
        }
开发者ID:fairygui,项目名称:FairyGUI-unity,代码行数:59,代码来源:UIPackage.cs


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