Ejemplo n.º 1
0
        private bool SetSpriteReal(Image _img, ImageScript _script, string _name, bool _doNotDispose)
        {
            TextureFactoryUnit <Sprite> unit;

            Dictionary <string, ITextureFactoryUnit> tmpDic;

            if (_doNotDispose)
            {
                tmpDic = dic;
            }
            else
            {
                tmpDic = dicWillDispose;
            }

            if (!tmpDic.ContainsKey(_name))
            {
                unit = new TextureFactoryUnit <Sprite> (_name);

                tmpDic.Add(_name, unit);
            }
            else
            {
                unit = tmpDic [_name] as TextureFactoryUnit <Sprite>;
            }

            Action <Sprite> callBack = delegate(Sprite obj) {
                GetSprite(_img, _script, _name, _doNotDispose, obj);
            };

            Sprite result = unit.GetTexture(callBack);

            if (result == null)
            {
                _img.color = new Color(1, 1, 1, 0);

                Action <float> tween = delegate(float obj) {
                    ChangeImageAlpha(_img, obj);
                };

                Action <Sprite> startTween = delegate(Sprite obj) {
                    SuperTween.Instance.To(0, 1, 0.1f, tween, null);
                };

                unit.GetTexture(startTween);

                return(true);
            }
            else
            {
                _img.color = Color.white;

                return(false);
            }
        }
Ejemplo n.º 2
0
        private void GetSprite(Image _img, ImageScript _script, string _name, bool _doNotDispose, Sprite _sp)
        {
            if (!_doNotDispose)
            {
                if (_script.imgName != _name)
                {
                    return;
                }

                _script.isLoading = false;
            }

            _img.sprite = _sp;
        }
Ejemplo n.º 3
0
        internal static bool SetSpriteReal(Image _img, ImageScript _script, string _name, bool _doNotDispose, bool _alphaIn, Action _loadOverCallBack)
        {
            Action <Sprite> callBack = delegate(Sprite obj) {
                GetSprite(_img, _script, _name, obj, _loadOverCallBack);
            };

            Sprite result = TextureFactory.Instance.GetTexture <Sprite>(_name, callBack, _doNotDispose);

            if (result == null)
            {
                if (_alphaIn)
                {
                    _img.color = new Color(1, 1, 1, 0);

                    Action <float> tween = delegate(float obj) {
                        ChangeImageAlpha(_img, obj);
                    };

                    Action <Sprite> startTween = delegate(Sprite obj) {
                        SuperTween.Instance.To(0, 1, 0.1f, tween, null);
                    };

                    TextureFactory.Instance.GetTexture <Sprite>(_name, startTween, _doNotDispose);
                }
                else
                {
                    _img.color = Color.white;
                }

                return(true);
            }
            else
            {
                _img.color = Color.white;

//				if(_loadOverCallBack != null){
//
//					_loadOverCallBack();
//				}

                return(false);
            }
        }
Ejemplo n.º 4
0
        public bool SetSprite(Image _img, string _name, bool _doNotDispose)
        {
            ImageScript script = null;

            if (!_doNotDispose)
            {
                script = _img.GetComponent <ImageScript>();

                if (script == null)
                {
                    script = _img.gameObject.AddComponent <ImageScript>();

                    script.reloadCallBack = SetSpriteReal;
                }

                script.isLoading = true;

                script.imgName = _name;
            }

            return(SetSpriteReal(_img, script, _name, _doNotDispose));
        }
Ejemplo n.º 5
0
        public static bool SetSprite(Image _img, string _name, bool _doNotDispose, bool _autoReload, bool _alphaIn, Action _loadOverCallBack, Action _reloadOverCallBack)
        {
            ImageScript script = null;

            if (!_doNotDispose && _autoReload)
            {
                script = _img.GetComponent <ImageScript>();

                if (script == null)
                {
                    script = _img.gameObject.AddComponent <ImageScript>();
                }

                script.isLoading = true;

                script.imgName = _name;

                script.alphaIn = _alphaIn;

                script.reloadOverCallBack = _reloadOverCallBack;
            }

            return(SetSpriteReal(_img, script, _name, _doNotDispose, _alphaIn, _loadOverCallBack));
        }
Ejemplo n.º 6
0
        private static void GetSprite(Image _img, ImageScript _script, string _name, Sprite _sp, Action _loadOverCallBack)
        {
            if (_img == null)
            {
                return;
            }

            if (_script != null)
            {
                if (_script.imgName != _name)
                {
                    return;
                }

                _script.isLoading = false;
            }

            _img.sprite = _sp;

            if (_loadOverCallBack != null)
            {
                _loadOverCallBack();
            }
        }