// *********************************************************************** // Assembly : Game // Author : Kimch // Created : 2020-09-02 // Description : // Last Modified By : // Last Modified On : // *********************************************************************** // // // *********************************************************************** using UnityEngine; namespace G { /// /// /// public class Ef_blood : MonoBehaviour { private float _startTime; private int _index; private int _oldIndex = -1; private Vector2 _size; private Renderer _renderer; private MaterialPropertyBlock _propertyBlock; /// /// /// void UpdateUV() { _startTime += Time.deltaTime; _index = (int)(_startTime * 22f); if (_index != _oldIndex) { if (_index >= 16) { this.transform.position = Vector3.one * 3f; _startTime = 0f; _index = 0; this.gameObject.SetActive(false); } var offset = new Vector2(_index % 4 * _size.x, 1f - _size.y - _index / 4 * _size.y); _propertyBlock.SetVector("_MainTex_ST", new Vector4(_size.x, _size.y, offset.x, offset.y)); //_renderer.material.mainTextureOffset = offset; //_renderer.material.mainTextureScale = _size; _oldIndex = _index; } } private void Awake() { _propertyBlock = new MaterialPropertyBlock(); _renderer = this.GetComponent(); _size = Vector2.one * 0.25f; this.gameObject.SetActive(false); } private void Update() { var position = this.transform.position; if (position.y >= 1f) { return; } UpdateUV(); } } }