Exemple #1
0
        /// <summary>
        /// 设置纹理资源
        /// </summary>
        /// <param name="textureExtSpriteAsset"></param>
        public override void SetTextureExtSpriteAsset(TextureExtSpriteAsset textureExtSpriteAsset)
        {
            // 清除原资源
            if (_textureExtSpriteAsset != null)
            {
                _textureExtSpriteAsset.Unuse();
            }

            _textureExtSpriteAsset = textureExtSpriteAsset;

            if (_textureExtSpriteAsset != null)
            {
                // 重设当前帧
                _gameObject.SetActive(true);
                _maxFrameIndex = _textureExtSpriteAsset.textureExtSprite.spriteCount - 1;
                frameIndex     = _frameIndex;
                _textureExtSpriteAsset.Use();
                MaterialPropertyBlock mpb = new MaterialPropertyBlock();
                _renderer.GetPropertyBlock(mpb);
                mpb.SetTexture("_AlphaTex", _textureExtSpriteAsset.textureExtSprite.texture.alphaTexture);
                _renderer.SetPropertyBlock(mpb);
            }
            else
            {
                // 隐藏当前帧
                _renderer.sprite = null;
                _gameObject.SetActive(false);
            }
        }
        /// <summary>
        /// 设置纹理资源
        /// </summary>
        /// <param name="textureExtSpriteAsset"></param>
        public virtual void SetTextureExtSpriteAsset(TextureExtSpriteAsset textureExtSpriteAsset)
        {
            // 清除原资源
            if (_textureExtSpriteAsset != null)
            {
                _textureExtSpriteAsset.Unuse();
            }

            _textureExtSpriteAsset = textureExtSpriteAsset;

            if (_textureExtSpriteAsset != null)
            {
                // 重设当前帧
                _gameObject.SetActive(true);
                _maxFrameIndex = _textureExtSpriteAsset.textureExtSprite.spriteCount - 1;
                frameIndex     = _frameIndex;
                _textureExtSpriteAsset.Use();
                _material.SetTexture("_AlphaTex", _textureExtSpriteAsset.textureExtSprite.texture.alphaTexture);
            }
            else
            {
                // 隐藏当前帧
                _renderer.sprite = null;
                _gameObject.SetActive(false);
                _material.SetTexture("_AlphaTex", null);
            }
        }
Exemple #3
0
        /// <summary>
        /// 设置纹理资源
        /// </summary>
        /// <param name="textureExtSpriteAsset"></param>
        /// <param name="name"></param>
        public virtual void SetTextureExtAsset(TextureExtSpriteAsset textureExtSpriteAsset, string name = null)
        {
            // 清除原资源
            if (_textureExtSpriteAsset != null)
            {
                _textureExtSpriteAsset.Unuse();
            }

            _textureExtSpriteAsset = textureExtSpriteAsset;

            if (_textureExtSpriteAsset != null)
            {
                // 重设当前帧
                _gameObject.SetActive(true);
                if (name != null)
                {
                    SetTextureName(name);
                    _material.SetTexture("_AlphaTex", textureExtSpriteAsset.textureExtSprite.texture.alphaTexture);
                }
                else
                {
                    _material.SetTexture("_AlphaTex", null);
                }
                _textureExtSpriteAsset.Use();
            }
            else
            {
                // 隐藏当前帧
                _renderer.sprite = null;
                _gameObject.SetActive(false);
                _material.SetTexture("_AlphaTex", null);
            }
        }
Exemple #4
0
        /// <summary>
        /// 设置纹理资源
        /// </summary>
        /// <param name="textureExtSpriteAsset"></param>
        /// <param name="name"></param>
        public override void SetTextureExtAsset(TextureExtSpriteAsset textureExtSpriteAsset, string name = null)
        {
            // 清除原资源
            if (_textureExtSpriteAsset != null)
            {
                _textureExtSpriteAsset.Unuse();
            }

            _textureExtSpriteAsset = textureExtSpriteAsset;

            if (_textureExtSpriteAsset != null)
            {
                // 重设当前帧
                _gameObject.SetActive(true);
                if (name != null)
                {
                    SetTextureName(name);
                    MaterialPropertyBlock mpb = new MaterialPropertyBlock();
                    _renderer.GetPropertyBlock(mpb);
                    mpb.SetTexture("_AlphaTex", _textureExtSpriteAsset.textureExtSprite.texture.alphaTexture);
                    _renderer.SetPropertyBlock(mpb);
                }
                else
                {
                    MaterialPropertyBlock mpb = new MaterialPropertyBlock();
                    _renderer.GetPropertyBlock(mpb);
                    mpb.SetTexture("_AlphaTex", null);
                    _renderer.SetPropertyBlock(mpb);
                }
                _textureExtSpriteAsset.Use();
            }
            else
            {
                // 隐藏当前帧
                _renderer.sprite = null;
                _gameObject.SetActive(false);
            }
        }