1. Step3์์ ๋ง๋ค์ด๋์ Test Plane์๋ค๊ฐ ์๋์ Script๋ฅผ ์ถ๊ฐ
Sprite.cs
using UnityEngine;
using System.Collections;
public enum SpriteType {
Once,
Loop,
}
public class Sprite : MonoBehaviour {
public SpriteType _Type;
public string _TextureName; // texture Name
public int _MaxFrame; // Texture Frame Length
public float _Dealay; // Sprite play Dealay
private TPHelper _TPH;
private int _NowFrame; // now frame Num
void Awake() {
_TPH = GetComponent<TPHelper>();
}
// Use this for initialization
void Start () {
_NowFrame = 1;
StartCoroutine(PlaySprite());
}
// Update is called once per frame
void Update () {
}
IEnumerator PlaySprite() { //is Recursion Function
_NowFrame++;
yield return new WaitForSeconds(_Dealay);
_TPH.OnTextureChange(_TextureName + _NowFrame.ToString());
if(_NowFrame == _MaxFrame && _Type == SpriteType.Loop) _NowFrame = 0;
if(_NowFrame == _MaxFrame && _Type == SpriteType.Once) yield return null;
if(_NowFrame != _MaxFrame) {
StartCoroutine(PlaySprite());
}
}
}
ps. ๊ฐ์ฅ ์ต๋ํ ์ดํดํ๊ธฐ ์ฝ๊ฒ๋ ์์ฑํ ์ฝ๋๋ผ์ ๋์ด๋ ์ธก๋ฉด์์๋ ์์ฃผ ์ฌ์ฐ์ค๋ฏ.
์ด๋ฐ์์ผ๋ก TPHelper ์ปดํฌ๋ํธ์ ์ ๊ทผํ์ฌ์ Texture ์์ , Atlas๋ณ๊ฒฝ์ ํ ์์์ผ๋
์
๋ง๋๋ก ์ฝ๋ฉํ์
์ ์ฌ์ฉํ์๋ฉด๋ฉ๋๋ค ^ใ
ก^














