예제 #1
0
        /// <summary>
        /// 创建Sprite
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        private Sprite CreateSprite(string name)
        {
            TextureExtParam param  = _texture.GetParam(name);
            Sprite          sprite = Sprite.Create(_texture.texture, param.rect, param.uv, 1);

            _spriteList[param.index] = sprite;
            _spriteDict[name]        = sprite;
            return(sprite);
        }
예제 #2
0
        /// <summary>
        /// 创建Sprite
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        private Sprite CreateSprite(int index)
        {
            TextureExtParam param  = _texture.GetParam(index);
            Sprite          sprite = Sprite.Create(_texture.texture, param.rect, param.uv, 1);

            _spriteList[index]      = sprite;
            _spriteDict[param.name] = sprite;
            return(sprite);
        }
예제 #3
0
        public void Init(string fileName, AssetBundle assetBundle)
        {
            this.fileName = fileName;
            texture       = assetBundle.LoadAsset <Texture2D>(fileName + TEXTURE_SUFFIX);
            alphaTexture  = assetBundle.LoadAsset <Texture2D>(fileName + ALPHA_TEXTURE_SUFFIX);

            TextureExtParams extParams;

            if (paramsCache.TryGetValue(fileName, out extParams))
            {
                paramList = extParams.paramList;
                paramDict = extParams.paramDict;
            }
            else
            {
                string   paramText = assetBundle.LoadAsset <TextAsset>(fileName + PARAM_SUFFIX).text;
                string[] lines     = paramText.Split(StringUtil.WARP, StringSplitOptions.None);
                paramList = new TextureExtParam[lines.Length - 1];
                paramDict = new Dictionary <string, TextureExtParam>();
                for (int i = 0; i < lines.Length - 1; i++)
                {
                    string          line       = lines[i];
                    string[]        paramArray = line.Split(';');
                    TextureExtParam param      = new TextureExtParam();
                    param.index           = i;
                    param.name            = paramArray[0];
                    param.rect            = new Rect(float.Parse(paramArray[1]), float.Parse(paramArray[2]), float.Parse(paramArray[3]), float.Parse(paramArray[4]));
                    param.uv              = new Vector2(float.Parse(paramArray[5]), float.Parse(paramArray[6]));
                    paramList[i]          = param;
                    paramDict[param.name] = param;
                }

                extParams             = new TextureExtParams();
                extParams.paramList   = paramList;
                extParams.paramDict   = paramDict;
                paramsCache[fileName] = extParams;
            }
        }