FairyGUI.GObjectPool.GetObject C# (CSharp) Method

GetObject() public method

public GetObject ( string url ) : GObject
url string
return GObject
        public GObject GetObject(string url)
        {
            Queue<GObject> arr;
            if (!_pool.TryGetValue(url, out arr))
            {
                arr = new Queue<GObject>();
                _pool.Add(url, arr);
            }

            if (arr.Count > 0)
            {
                return arr.Dequeue();
            }

            GObject obj = UIPackage.CreateObjectFromURL(url);
            if (obj != null)
            {
                if (initCallback != null)
                    initCallback(obj);
            }

            return obj;
        }

Usage Example

示例#1
0
        private void SetErrorState()
        {
            if (!showErrorSign || !Application.isPlaying)
            {
                return;
            }

            if (_errorSign == null)
            {
                if (UIConfig.loaderErrorSign != null)
                {
                    if (errorSignPool == null)
                    {
                        errorSignPool = new GObjectPool(Stage.inst.CreatePoolManager("LoaderErrorSignPool"));
                    }

                    _errorSign = errorSignPool.GetObject(UIConfig.loaderErrorSign);
                }
                else
                {
                    return;
                }
            }

            if (_errorSign != null)
            {
                _errorSign.SetSize(this.width, this.height);
                ((Container)displayObject).AddChild(_errorSign.displayObject);
            }
        }
All Usage Examples Of FairyGUI.GObjectPool::GetObject