01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
public
bool
ActivateWait =
false
;
float
fireRate = 0.2f;
int
i = 0;
float
nextFire;
string
[] ActivatorTexture =
new
string
[] {
"activity00"
,
"activity01"
,
"activity02"
,
"activity03"
,
"activity04"
,
"activity05"
,
"activity06"
,
"activity07"
,
"activity08"
,
"activity09"
,
"activity10"
,
"activity11"
};
//这里存放我们需要调用的序列帧的名称,这种方法比较笨拙,
//只适合使用图片较少的情况,当图片很多的情况下,我们可以使用代码控制名称,思路是前面的名称一样,后面的名称代表序列帧编号,我们只要
//在代码中根据编号加上前缀名称就可以得到所需序列帧的全名。具体使用参见下面的Texture序列帧动画。
void
Awake()
{
this
.GetComponent<UISprite>().enabled =
false
;
}
// Use this for initialization
void
Start()
{
}
// Update is called once per frame
void
Update()
{
if
(ActivateWait)
{
this
.GetComponent<UISprite>().enabled =
true
;
if
(i < ActivatorTexture.Length)
{
if
(Time.time > nextFire)
{
nextFire = Time.time + fireRate;
this
.GetComponent<UISprite>().spriteName= ActivatorTexture;
i++;
}
}
else
{
i = 0;
}
}
else
{
this
.GetComponent<UISprite>().enabled =
false
;
}
}
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
void
DynamicLoadUnload(
int
curframe )
{
//plane.renderer.material.mainTexture=ani[currentFrame];
if
(curframe < 10)
//这里判断当前帧
{
TextureUI.mainTexture = (Texture2D)Resources.Load(SequenceName_Gewei + curframe.ToString(),
typeof
(Texture2D));
//SequenceName_Gewei 是指序列帧的名称去掉各位数字的名称,比如全名为Texture00,那么这里的参数应该是Texture0。下面还有十位百位,
//依次类推。这里是根据名称加帧索引,获取全名的。
}
else
if
(curframe >= 10 && curframe < 100)
{
if
(curframe % 50 == 0)
Resources.UnloadUnusedAssets();
TextureUI.mainTexture = (Texture2D)Resources.Load(SequenceName_Shiwei + curframe.ToString(),
typeof
(Texture2D));
}
else
{
if
(curframe % 50 == 0)
Resources.UnloadUnusedAssets();
TextureUI.mainTexture = (Texture2D)Resources.Load(SequenceName_Baiwei + curframe.ToString(),
typeof
(Texture2D));
}
}
|