GetItemAssetByURL() public static method

Get a asset with a certain name.
public static GetItemAssetByURL ( string url ) : object
url string Resource url.
return object
Example #1
0
        override public void Setup_AfterAdd(XML cxml)
        {
            base.Setup_AfterAdd(cxml);

            if (_downEffect == 2)
            {
                this.SetPivot(0.5f, 0.5f);
            }

            XML xml = cxml.GetNode("Button");

            if (xml == null)
            {
                this.title = string.Empty;
                this.icon  = null;
                return;
            }

            string str;

            this.title = xml.GetAttribute("title");
            this.icon  = xml.GetAttribute("icon");
            str        = xml.GetAttribute("selectedTitle");
            if (str != null)
            {
                this.selectedTitle = str;
            }
            str = xml.GetAttribute("selectedIcon");
            if (str != null)
            {
                this.selectedIcon = str;
            }

            str = xml.GetAttribute("titleColor");
            if (str != null)
            {
                this.titleColor = ToolSet.ConvertFromHtmlColor(str);
            }
            str = xml.GetAttribute("controller");
            if (str != null)
            {
                _relatedController = parent.GetController(str);
            }
            pageOption.id = xml.GetAttribute("page");
            this.selected = xml.GetAttributeBool("checked", false);

            str = xml.GetAttribute("sound");
            if (str != null)
            {
                sound = UIPackage.GetItemAssetByURL(str) as AudioClip;
            }

            str = xml.GetAttribute("volume");
            if (str != null)
            {
                soundVolumeScale = float.Parse(str) / 100f;
            }
        }
 internal static AudioClip LoadSound(string url)
 {
     if (soundLoader == null || url.StartsWith(UIPackage.URL_PREFIX))
     {
         return(UIPackage.GetItemAssetByURL(url) as AudioClip);
     }
     else
     {
         return(soundLoader(url));
     }
 }
Example #3
0
        override public void ConstructFromXML(XML cxml)
        {
            base.ConstructFromXML(cxml);

            XML xml = cxml.GetNode("Button");

            string str;

            str = xml.GetAttribute("mode");
            if (str != null)
            {
                _mode = FieldTypes.ParseButtonMode(str);
            }
            else
            {
                _mode = ButtonMode.Common;
            }

            str = xml.GetAttribute("sound");
            if (str != null)
            {
                sound = UIPackage.GetItemAssetByURL(str) as AudioClip;
            }

            str = xml.GetAttribute("volume");
            if (str != null)
            {
                soundVolumeScale = float.Parse(str) / 100f;
            }

            str = xml.GetAttribute("downEffect");
            if (str != null)
            {
                _downEffect      = str == "dark" ? 1 : (str == "scale" ? 2 : 0);
                _downEffectValue = xml.GetAttributeFloat("downEffectValue");
            }

            _buttonController = GetController("button");
            _titleObject      = GetChild("title");
            _iconObject       = GetChild("icon");

            if (_mode == ButtonMode.Common)
            {
                SetState(UP);
            }

            displayObject.onRollOver.Add(__rollover);
            displayObject.onRollOut.Add(__rollout);
            displayObject.onTouchBegin.Add(__touchBegin);
            displayObject.onTouchEnd.Add(__touchEnd);
            displayObject.onRemovedFromStage.Add(__removedFromStage);
            displayObject.onClick.Add(__click);
        }
Example #4
0
        override public void Setup_AfterAdd(ByteBuffer buffer, int beginPos)
        {
            base.Setup_AfterAdd(buffer, beginPos);

            if (!buffer.Seek(beginPos, 6))
            {
                Update(_value);
                return;
            }

            if ((ObjectType)buffer.ReadByte() != packageItem.objectType)
            {
                Update(_value);
                return;
            }

            _value = buffer.ReadInt();
            _max   = buffer.ReadInt();
            if (buffer.version >= 2)
            {
                _min = buffer.ReadInt();
            }

            if (buffer.version >= 5)
            {
                string sound = buffer.ReadS();
                if (!string.IsNullOrEmpty(sound))
                {
                    float volumeScale = buffer.ReadFloat();
                    displayObject.onClick.Add(() =>
                    {
                        NAudioClip audioClip = UIPackage.GetItemAssetByURL(sound) as NAudioClip;
                        if (audioClip != null && audioClip.nativeClip != null)
                        {
                            Stage.inst.PlayOneShotSound(audioClip.nativeClip, volumeScale);
                        }
                    });
                }
                else
                {
                    buffer.Skip(4);
                }
            }

            Update(_value);
        }
Example #5
0
        override protected void ConstructExtension(ByteBuffer buffer)
        {
            buffer.Seek(0, 6);

            _mode = (ButtonMode)buffer.ReadByte();
            string str = buffer.ReadS();

            if (str != null)
            {
                sound = UIPackage.GetItemAssetByURL(str) as NAudioClip;
            }
            soundVolumeScale = buffer.ReadFloat();
            _downEffect      = buffer.ReadByte();
            _downEffectValue = buffer.ReadFloat();
            if (_downEffect == 2)
            {
                SetPivot(0.5f, 0.5f, this.pivotAsAnchor);
            }

            _buttonController = GetController("button");
            _titleObject      = GetChild("title");
            _iconObject       = GetChild("icon");
            if (_titleObject != null)
            {
                _title = _titleObject.text;
            }
            if (_iconObject != null)
            {
                _icon = _iconObject.icon;
            }

            if (_mode == ButtonMode.Common)
            {
                SetState(UP);
            }

            displayObject.onRollOver.Add(__rollover);
            displayObject.onRollOut.Add(__rollout);
            displayObject.onTouchBegin.Add(__touchBegin);
            displayObject.onTouchEnd.Add(__touchEnd);
            displayObject.onRemovedFromStage.Add(__removedFromStage);
            displayObject.onClick.Add(__click);
        }
Example #6
0
        public void Play()
        {
            if (audioClip == null)
            {
                if (UIConfig.soundLoader == null || sound.StartsWith(UIPackage.URL_PREFIX))
                {
                    audioClip = UIPackage.GetItemAssetByURL(sound) as AudioClip;
                }
                else
                {
                    audioClip = UIConfig.soundLoader(sound);
                }
            }

            if (audioClip != null)
            {
                Stage.inst.PlayOneShotSound(audioClip, volume);
            }
        }
Example #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        static public BaseFont GetFont(string name, Font font = null)
        {
            BaseFont ret;

            if (name.StartsWith(UIPackage.URL_PREFIX))
            {
                ret = UIPackage.GetItemAssetByURL(name) as BaseFont;
                if (ret != null)
                {
                    return(ret);
                }
            }

            if (!sFontFactory.TryGetValue(name, out ret))
            {
                ret = new DynamicFont(name, font);
                sFontFactory.Add(name, ret);
            }

            return(ret);
        }
Example #8
0
        public void Load()
        {
            int cnt = Items.Count;

            for (int i = 0; i < cnt; i++)
            {
                ConfigValue value = Items[i];
                if (!value.valid)
                {
                    continue;
                }

                switch ((UIConfig.ConfigKey)i)
                {
                case ConfigKey.ButtonSound:
                    if (Application.isPlaying)
                    {
                        UIConfig.buttonSound = UIPackage.GetItemAssetByURL(value.s) as NAudioClip;
                    }
                    break;

                case ConfigKey.ButtonSoundVolumeScale:
                    UIConfig.buttonSoundVolumeScale = value.f;
                    break;

                case ConfigKey.ClickDragSensitivity:
                    UIConfig.clickDragSensitivity = value.i;
                    break;

                case ConfigKey.DefaultComboBoxVisibleItemCount:
                    UIConfig.defaultComboBoxVisibleItemCount = value.i;
                    break;

                case ConfigKey.DefaultFont:
                    UIConfig.defaultFont = value.s;
                    break;

                case ConfigKey.DefaultScrollBarDisplay:
                    UIConfig.defaultScrollBarDisplay = (ScrollBarDisplayType)value.i;
                    break;

                case ConfigKey.DefaultScrollBounceEffect:
                    UIConfig.defaultScrollBounceEffect = value.b;
                    break;

                case ConfigKey.DefaultScrollStep:
                    UIConfig.defaultScrollStep = value.i;
                    break;

                case ConfigKey.DefaultScrollTouchEffect:
                    UIConfig.defaultScrollTouchEffect = value.b;
                    break;

                case ConfigKey.GlobalModalWaiting:
                    UIConfig.globalModalWaiting = value.s;
                    break;

                case ConfigKey.HorizontalScrollBar:
                    UIConfig.horizontalScrollBar = value.s;
                    break;

                case ConfigKey.LoaderErrorSign:
                    UIConfig.loaderErrorSign = value.s;
                    break;

                case ConfigKey.ModalLayerColor:
                    UIConfig.modalLayerColor = value.c;
                    break;

                case ConfigKey.PopupMenu:
                    UIConfig.popupMenu = value.s;
                    break;

                case ConfigKey.PopupMenu_seperator:
                    UIConfig.popupMenu_seperator = value.s;
                    break;

                case ConfigKey.TooltipsWin:
                    UIConfig.tooltipsWin = value.s;
                    break;

                case ConfigKey.TouchDragSensitivity:
                    UIConfig.touchDragSensitivity = value.i;
                    break;

                case ConfigKey.TouchScrollSensitivity:
                    UIConfig.touchScrollSensitivity = value.i;
                    break;

                case ConfigKey.VerticalScrollBar:
                    UIConfig.verticalScrollBar = value.s;
                    break;

                case ConfigKey.WindowModalWaiting:
                    UIConfig.windowModalWaiting = value.s;
                    break;

                case ConfigKey.AllowSoftnessOnTopOrLeftSide:
                    UIConfig.allowSoftnessOnTopOrLeftSide = value.b;
                    break;

                case ConfigKey.InputCaretSize:
                    UIConfig.inputCaretSize = value.i;
                    break;

                case ConfigKey.InputHighlightColor:
                    UIConfig.inputHighlightColor = value.c;
                    break;

                case ConfigKey.DepthSupportForPaintingMode:
                    UIConfig.depthSupportForPaintingMode = value.b;
                    break;

                case ConfigKey.EnhancedTextOutlineEffect:
                    UIConfig.enhancedTextOutlineEffect = value.b;
                    break;

                case ConfigKey.Branch:
                    UIPackage.branch = value.s;
                    break;
                }
            }
        }
Example #9
0
        void ApplyValue(TransitionItem item, TransitionValue value)
        {
            item.target._gearLocked = true;

            switch (item.type)
            {
            case TransitionActionType.XY:
                if (item.target == _owner)
                {
                    float f1, f2;
                    if (!value.b1)
                    {
                        f1 = item.target.x;
                    }
                    else
                    {
                        f1 = value.f1 + _ownerBaseX;
                    }
                    if (!value.b2)
                    {
                        f2 = item.target.y;
                    }
                    else
                    {
                        f2 = value.f2 + _ownerBaseY;
                    }
                    item.target.SetXY(f1, f2);
                }
                else
                {
                    if (!value.b1)
                    {
                        value.f1 = item.target.x;
                    }
                    if (!value.b2)
                    {
                        value.f2 = item.target.y;
                    }
                    item.target.SetXY(value.f1, value.f2);
                }
                break;

            case TransitionActionType.Size:
                if (!value.b1)
                {
                    value.f1 = item.target.width;
                }
                if (!value.b2)
                {
                    value.f2 = item.target.height;
                }
                item.target.SetSize(value.f1, value.f2);
                break;

            case TransitionActionType.Pivot:
                item.target.SetPivot(value.f1, value.f2);
                break;

            case TransitionActionType.Alpha:
                item.target.alpha = value.f1;
                break;

            case TransitionActionType.Rotation:
                item.target.rotation = value.i;
                break;

            case TransitionActionType.Scale:
                item.target.SetScale(value.f1, value.f2);
                break;

            case TransitionActionType.Color:
                ((IColorGear)item.target).color = value.c;
                break;

            case TransitionActionType.Animation:
                if (!value.b1)
                {
                    value.i = ((IAnimationGear)item.target).frame;
                }
                ((IAnimationGear)item.target).frame   = value.i;
                ((IAnimationGear)item.target).playing = value.b;
                break;

            case TransitionActionType.Visible:
                item.target.visible = value.b;
                break;

            case TransitionActionType.Controller:
                string[] arr = value.s.Split(',');
                foreach (string str in arr)
                {
                    string[]   arr2 = str.Split('=');
                    Controller cc   = ((GComponent)item.target).GetController(arr2[0]);
                    if (cc != null)
                    {
                        string str2 = arr2[1];
                        if (str2[0] == '$')
                        {
                            str2            = str.Substring(1);
                            cc.selectedPage = str2;
                        }
                        else
                        {
                            cc.selectedIndex = int.Parse(str2);
                        }
                    }
                }
                break;

            case TransitionActionType.Transition:
                Transition trans = ((GComponent)item.target).GetTransition(value.s);
                if (trans != null)
                {
                    if (value.i == 0)
                    {
                        trans.Stop(false, true);
                    }
                    else if (trans.playing)
                    {
                        trans._totalTimes = value.i == -1 ? int.MaxValue : value.i;
                    }
                    else
                    {
                        item.completed = false;
                        _totalTasks++;
                        if (_reversed)
                        {
                            trans.PlayReverse(value.i, 0, () => { __playTransComplete(item); });
                        }
                        else
                        {
                            trans.Play(value.i, 0, () => { __playTransComplete(item); });
                        }
                    }
                }
                break;

            case TransitionActionType.Sound:
                AudioClip sound = UIPackage.GetItemAssetByURL(value.s) as AudioClip;
                if (sound != null)
                {
                    Stage.inst.PlayOneShotSound(sound, value.f1);
                }
                break;

            case TransitionActionType.Shake:
                item.startValue.f1 = 0;                         //offsetX
                item.startValue.f2 = 0;                         //offsetY
                item.startValue.f3 = item.value.f2;             //shakePeriod
                Timers.inst.AddUpdate(item.__Shake, this);
                _totalTasks++;
                item.completed = false;
                break;
            }

            item.target._gearLocked = false;
        }
Example #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        static public BaseFont GetFont(string name)
        {
            BaseFont font;

            if (name.StartsWith(UIPackage.URL_PREFIX))
            {
                font = UIPackage.GetItemAssetByURL(name) as BaseFont;
                if (font != null)
                {
                    return(font);
                }
            }

            if (sFontFactory.TryGetValue(name, out font))
            {
                return(font);
            }

            object asset = null;

            if (Regex.IsMatch(name, ".ttf"))
            {
                asset = libx.Assets.LoadAsset("Assets/Res/Fonts/" + name, typeof(UnityEngine.Font)).asset;
            }
            else
            {
                asset = Resources.Load(name);
            }

            if (asset == null)
            {
                asset = Resources.Load("Fonts/" + name);
            }

            //Try to use new API in Uinty5 to load
            if (asset == null)
            {
                if (name.IndexOf(",") != -1)
                {
                    string[] arr = name.Split(',');
                    int      cnt = arr.Length;
                    for (int i = 0; i < cnt; i++)
                    {
                        arr[i] = arr[i].Trim();
                    }
                    asset = Font.CreateDynamicFontFromOSFont(arr, 16);
                }
                else
                {
                    asset = Font.CreateDynamicFontFromOSFont(name, 16);
                }
            }

            if (asset == null)
            {
                return(Fallback(name));
            }

            if (asset is Font)
            {
                font      = new DynamicFont();
                font.name = name;
                sFontFactory.Add(name, font);

                ((DynamicFont)font).nativeFont = (Font)asset;
            }
#if FAIRYGUI_TMPRO
            else if (asset is TMPro.TMP_FontAsset)
            {
                font      = new TMPFont();
                font.name = name;
                sFontFactory.Add(name, font);
                ((TMPFont)font).fontAsset = (TMPro.TMP_FontAsset)asset;
            }
#endif
            else
            {
                if (asset.GetType().Name.Contains("TMP_FontAsset"))
                {
                    Debug.LogWarning("To enable TextMeshPro support, add script define symbol: FAIRYGUI_TMPRO");
                }

                return(Fallback(name));
            }

            return(font);
        }
Example #11
0
        override public void Setup_AfterAdd(ByteBuffer buffer, int beginPos)
        {
            base.Setup_AfterAdd(buffer, beginPos);

            if (!buffer.Seek(beginPos, 6))
            {
                return;
            }

            if ((ObjectType)buffer.ReadByte() != packageItem.objectType)
            {
                return;
            }

            string str;

            str = buffer.ReadS();
            if (str != null)
            {
                this.title = str;
            }
            str = buffer.ReadS();
            if (str != null)
            {
                this.selectedTitle = str;
            }
            str = buffer.ReadS();
            if (str != null)
            {
                this.icon = str;
            }
            str = buffer.ReadS();
            if (str != null)
            {
                this.selectedIcon = str;
            }
            if (buffer.ReadBool())
            {
                this.titleColor = buffer.ReadColor();
            }
            int iv = buffer.ReadInt();

            if (iv != 0)
            {
                this.titleFontSize = iv;
            }
            iv = buffer.ReadShort();
            if (iv >= 0)
            {
                _relatedController = parent.GetControllerAt(iv);
            }
            _relatedPageId = buffer.ReadS();

            str = buffer.ReadS();
            if (str != null)
            {
                sound = UIPackage.GetItemAssetByURL(str) as NAudioClip;
            }
            if (buffer.ReadBool())
            {
                soundVolumeScale = buffer.ReadFloat();
            }

            this.selected = buffer.ReadBool();
        }
Example #12
0
        void ApplyValue(TransitionItem item, TransitionValue value)
        {
            item.target._gearLocked = true;

            switch (item.type)
            {
            case TransitionActionType.XY:
                if (item.target == _owner)
                {
                    float f1, f2;
                    if (!value.b1)
                    {
                        f1 = item.target.x;
                    }
                    else
                    {
                        f1 = value.f1 + _ownerBaseX;
                    }
                    if (!value.b2)
                    {
                        f2 = item.target.y;
                    }
                    else
                    {
                        f2 = value.f2 + _ownerBaseY;
                    }
                    item.target.SetXY(f1, f2);
                }
                else
                {
                    if (!value.b1)
                    {
                        value.f1 = item.target.x;
                    }
                    if (!value.b2)
                    {
                        value.f2 = item.target.y;
                    }
                    item.target.SetXY(value.f1, value.f2);
                }
                if (invalidateBatchingEveryFrame)
                {
                    _owner.InvalidateBatchingState();
                }
                break;

            case TransitionActionType.Size:
                if (!value.b1)
                {
                    value.f1 = item.target.width;
                }
                if (!value.b2)
                {
                    value.f2 = item.target.height;
                }
                item.target.SetSize(value.f1, value.f2);
                if (invalidateBatchingEveryFrame)
                {
                    _owner.InvalidateBatchingState();
                }
                break;

            case TransitionActionType.Pivot:
                item.target.SetPivot(value.f1, value.f2);
                if (invalidateBatchingEveryFrame)
                {
                    _owner.InvalidateBatchingState();
                }
                break;

            case TransitionActionType.Alpha:
                item.target.alpha = value.f1;
                break;

            case TransitionActionType.Rotation:
                item.target.rotation = value.f1;
                if (invalidateBatchingEveryFrame)
                {
                    _owner.InvalidateBatchingState();
                }
                break;

            case TransitionActionType.Scale:
                item.target.SetScale(value.f1, value.f2);
                if (invalidateBatchingEveryFrame)
                {
                    _owner.InvalidateBatchingState();
                }
                break;

            case TransitionActionType.Skew:
                item.target.skew = new Vector2(value.f1, value.f2);
                if (invalidateBatchingEveryFrame)
                {
                    _owner.InvalidateBatchingState();
                }
                break;

            case TransitionActionType.Color:
                ((IColorGear)item.target).color = value.c;
                break;

            case TransitionActionType.Animation:
                if (!value.b1)
                {
                    value.i = ((IAnimationGear)item.target).frame;
                }
                ((IAnimationGear)item.target).frame   = value.i;
                ((IAnimationGear)item.target).playing = value.b;
                break;

            case TransitionActionType.Visible:
                item.target.visible = value.b;
                break;

            case TransitionActionType.Transition:
                Transition trans = ((GComponent)item.target).GetTransition(value.s);
                if (trans != null)
                {
                    if (value.i == 0)
                    {
                        trans.Stop(false, true);
                    }
                    else if (trans.playing)
                    {
                        trans._totalTimes = value.i == -1 ? int.MaxValue : value.i;
                    }
                    else
                    {
                        item.completed = false;
                        _totalTasks++;
                        if (_reversed)
                        {
                            trans.PlayReverse(value.i, 0, () => { __playTransComplete(item); });
                        }
                        else
                        {
                            trans.Play(value.i, 0, () => { __playTransComplete(item); });
                        }
                        if (_timeScale != 1)
                        {
                            trans.timeScale = _timeScale;
                        }
                    }
                }
                break;

            case TransitionActionType.Sound:
                AudioClip sound = UIPackage.GetItemAssetByURL(value.s) as AudioClip;
                if (sound != null)
                {
                    Stage.inst.PlayOneShotSound(sound, value.f1);
                }
                break;

            case TransitionActionType.Shake:
                item.startValue.f1 = 0;                         //offsetX
                item.startValue.f2 = 0;                         //offsetY
                item.startValue.f3 = item.value.f2;             //shakePeriod
                Timers.inst.AddUpdate(item.__Shake, this);
                _totalTasks++;
                item.completed = false;
                break;

            case TransitionActionType.ColorFilter:
                ColorFilter cf = item.target.filter as ColorFilter;
                if (cf == null)
                {
                    cf = new ColorFilter();
                    item.target.filter = cf;
                    item.filterCreated = true;
                }
                else
                {
                    cf.Reset();
                }
                cf.AdjustBrightness(value.f1);
                cf.AdjustContrast(value.f2);
                cf.AdjustSaturation(value.f3);
                cf.AdjustHue(value.f4);
                break;
            }

            item.target._gearLocked = false;
        }
Example #13
0
        override public void Setup_AfterAdd(ByteBuffer buffer, int beginPos)
        {
            base.Setup_AfterAdd(buffer, beginPos);

            if (!buffer.Seek(beginPos, 6))
            {
                return;
            }

            if ((ObjectType)buffer.ReadByte() != packageItem.objectType)
            {
                return;
            }

            string str;

            str = buffer.ReadS();
            if (str != null)
            {
                this.title = str;
            }
            str = buffer.ReadS();
            if (str != null)
            {
                this.icon = str;
            }
            if (buffer.ReadBool())
            {
                this.titleColor = buffer.ReadColor();
            }
            int iv = buffer.ReadInt();

            if (iv != 0)
            {
                this.titleFontSize = iv;
            }

            if (buffer.ReadBool())
            {
                GTextInput input = GetTextField() as GTextInput;
                if (input != null)
                {
                    str = buffer.ReadS();
                    if (str != null)
                    {
                        input.promptText = str;
                    }

                    str = buffer.ReadS();
                    if (str != null)
                    {
                        input.restrict = str;
                    }

                    iv = buffer.ReadInt();
                    if (iv != 0)
                    {
                        input.maxLength = iv;
                    }
                    iv = buffer.ReadInt();
                    if (iv != 0)
                    {
                        input.keyboardType = iv;
                    }
                    if (buffer.ReadBool())
                    {
                        input.displayAsPassword = true;
                    }
                }
                else
                {
                    buffer.Skip(13);
                }
            }

            if (buffer.version >= 5)
            {
                string sound = buffer.ReadS();
                if (!string.IsNullOrEmpty(sound))
                {
                    float volumeScale = buffer.ReadFloat();
                    displayObject.onClick.Add(() =>
                    {
                        NAudioClip audioClip = UIPackage.GetItemAssetByURL(sound) as NAudioClip;
                        if (audioClip != null && audioClip.nativeClip != null)
                        {
                            Stage.inst.PlayOneShotSound(audioClip.nativeClip, volumeScale);
                        }
                    });
                }
                else
                {
                    buffer.Skip(4);
                }
            }
        }
Example #14
0
        override public void Setup_AfterAdd(ByteBuffer buffer, int beginPos)
        {
            base.Setup_AfterAdd(buffer, beginPos);

            if (!buffer.Seek(beginPos, 6))
            {
                return;
            }

            if ((ObjectType)buffer.ReadByte() != packageItem.objectType)
            {
                return;
            }

            string str;
            int    itemCount = buffer.ReadShort();

            for (int i = 0; i < itemCount; i++)
            {
                int nextPos = buffer.ReadUshort();
                nextPos += buffer.position;

                _items.Add(buffer.ReadS());
                _values.Add(buffer.ReadS());
                str = buffer.ReadS();
                if (str != null)
                {
                    if (_icons == null)
                    {
                        _icons = new List <string>();
                    }
                    _icons.Add(str);
                }

                buffer.position = nextPos;
            }

            str = buffer.ReadS();
            if (str != null)
            {
                this.text      = str;
                _selectedIndex = _items.IndexOf(str);
            }
            else if (_items.Count > 0)
            {
                _selectedIndex = 0;
                this.text      = _items[0];
            }
            else
            {
                _selectedIndex = -1;
            }

            str = buffer.ReadS();
            if (str != null)
            {
                this.icon = str;
            }

            if (buffer.ReadBool())
            {
                this.titleColor = buffer.ReadColor();
            }
            int iv = buffer.ReadInt();

            if (iv > 0)
            {
                visibleItemCount = iv;
            }
            _popupDirection = (PopupDirection)buffer.ReadByte();

            iv = buffer.ReadShort();
            if (iv >= 0)
            {
                _selectionController = parent.GetControllerAt(iv);
            }

            if (buffer.version >= 5)
            {
                str = buffer.ReadS();
                if (str != null)
                {
                    sound = UIPackage.GetItemAssetByURL(str) as NAudioClip;
                }
                soundVolumeScale = buffer.ReadFloat();
            }
        }