unity3D用4个按钮播放4个不同的动画,在一个场景,求大神告知
我的按钮是用脚本生成的privatevoidOnGUI(){if(GUI.Button(newRect(150,200,80,40),"是"))}...
我的按钮是用脚本生成的
private void OnGUI()
{
if (GUI.Button(new Rect(150,200, 80, 40), "是"))
} 展开
private void OnGUI()
{
if (GUI.Button(new Rect(150,200, 80, 40), "是"))
} 展开
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");
}
}
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");
}
}
一诺动画
2024-10-27 广告
2024-10-27 广告
在北京一之诺文化传媒有限公司,我们专业承接高质量的3D动画制作项目。利用行业领先的软件技术与创意团队,我们能够将客户的想象力转化为栩栩如生的3D动画作品。从概念设计到模型构建,再到动画渲染与后期合成,每一步都力求精准与创新,为品牌传播、影视...
点击进入详情页
本回答由一诺动画提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询