Exemple #1
0
        protected GameObject getCacheImage()
        {
            GameObject ret = null;
            int        len = _cacheImg.Count;

            for (int i = 0; i < len; i++)
            {
                LCacheElement cacheElem = _cacheImg[i];
                if (cacheElem.isUse == false)
                {
                    cacheElem.isUse = true;
                    ret             = cacheElem.node;
                    break;
                }
            }
            if (ret == null)
            {
                ret = new GameObject();
                ret.AddComponent <Image>();
                ContentSizeFitter fit = ret.AddComponent <ContentSizeFitter>();
                fit.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;
                fit.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;

                RectTransform rtran = ret.GetComponent <RectTransform>();
                rtran.pivot     = Vector2.zero;
                rtran.anchorMax = new Vector2(0, 0);
                rtran.anchorMin = new Vector2(0, 0);

                LCacheElement cacheElem = new LCacheElement(ret);
                cacheElem.isUse = true;
                _cacheImg.Add(cacheElem);
            }
            return(ret);
        }
Exemple #2
0
        protected GameObject getCacheImage()
        {
            GameObject ret = null;
            int len = _cacheImg.Count;
            for (int i = 0; i < len; i++)
            {
                LCacheElement cacheElem = _cacheImg[i];
                if (cacheElem.isUse == false)
                {
                    cacheElem.isUse = true;
                    ret = cacheElem.node;
                    break;
                }
            }
            if (ret == null)
            {
                ret = new GameObject();
                ret.AddComponent<Image>();
                ContentSizeFitter fit = ret.AddComponent<ContentSizeFitter>();
                fit.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
                fit.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;

                RectTransform rtran = ret.GetComponent<RectTransform>();
                rtran.pivot = Vector2.zero;
                rtran.anchorMax = new Vector2(0, 0);
                rtran.anchorMin = new Vector2(0, 0);

                LCacheElement cacheElem = new LCacheElement(ret);
                cacheElem.isUse = true;
                _cacheImg.Add(cacheElem);
            }
            return ret;
        }