
方法/步骤
1首先,新建Canvas,在Canvas下新建Image作为背景,新建Text用来制作动画。
选中Canvas, 打开Window->Animation, 来到Animation窗口。
2.点击Create,选择保存动画片段的地方(通常是项目的Animation文件夹),创建。
3.创建过后,Canvas自动多了一个Animator组件,且自动创建了控制器(图中是Canvas 1)。动画控制器的使用本经验不展开说明。 现在可以进行动画编辑了。
4.点击Add Property, 可以把想要添加动画的属性添加进来。我们看到Text对象的Text Script组件下,可以给颜色等属性制作动画。
5.展开Text->Rect Transform, 点击Scale右边的小加号,把Scale属性添加到动画属性列表里。
6.展开Scale,我们看到三个子属性x,y,z。我们就是要对这三个数值打关键帧,制作动画。
7.首先,选中起始帧和结束帧,移动到自己觉得合适的地方。
8.在想要添加关键帧的地方添加一个关键帧。通过面板上面的两个小按钮,来回切换关键帧。
9.将起始帧的scale.x/y/z设置为0. 同理,分别设置中间帧和结束帧。
10.从面板下面切换到Curve,可以直观地看到三个属性值随时间的变化。最终效果如图。
注意事项
开启录制模式后,也可以直接在Inspector面板中,对红色的属性值进行修改,会自动添加关键帧。
1.创建脚本,写入这些并保存:public ParticleSystem pars
private void Update()
{
if (Input.GetKey(KeyCode.Alpha1))
pars.Play()//或者 pars.gameObject.SetActive(true)
}
2.把脚本挂到某个对象上,把那个有粒子的物体拖到脚本的Pars框里。
(将原先的粒子系统中“唤醒时播放”取消勾选。但如果是要出现,而不是播放,则不必进行该 *** 作)
4.运行。
5.按下数字键1时,粒子播放或出现。
如果你说的动画指的是animation的话,用OnGUI:public GameObject animobj
void OnGUI()
{
if (GUI.Button(new Rect(Screen.width * 0.01f, Screen.height * 0.01f, Screen.width * 0.1f, Screen.height * 0.1f), "play1"))
{
animobj.GetComponent<Animation>().Play("anim1")
}
if (GUI.Button(new Rect(Screen.width * 0.01f, Screen.height * 0.11f, Screen.width * 0.1f, Screen.height * 0.1f), "play2"))
{
animobj.GetComponent<Animation>().Play("anim2")
}
if (GUI.Button(new Rect(Screen.width * 0.01f, Screen.height * 0.21f, Screen.width * 0.1f, Screen.height * 0.1f), "play3"))
{
animobj.GetComponent<Animation>().Play("anim3")
}
if (GUI.Button(new Rect(Screen.width * 0.01f, Screen.height * 0.31f, Screen.width * 0.1f, Screen.height * 0.1f), "play4"))
{
animobj.GetComponent<Animation>().Play("anim4")
}
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)