List<Animation> storeAnimation;
public void Awake()
{
storeAnimation = new List<Animation>();
storeAnimation.Clear();
}
private void Update()
{
    //1. 获取鼠标点击位置
//创建射线;从摄像机发射一条经过鼠标当前位置的射线
  Ray ray = firstCamera.ScreenPointToRay(Input.mousePosition);
//发射射线
RaycastHit hitInfo = new RaycastHit();
if (Physics.Raycast(ray, out hitInfo))
{ if (hitInfo.collider.name == "plantLeftDoor01" || hitInfo.collider.name == "plantLeftDoor02" || hitInfo.collider.name == "plantLeftDoor03" || hitInfo.collider.name == "plantLeftDoor04" || hitInfo.collider.name == "plantLeftDoor05" || hitInfo.collider.name == "plantLeftDoor06" || hitInfo.collider.name == "plantLeftDoor07" || hitInfo.collider.name == "plantLeftDoor08")
{
OpenOrCloseLeftDoor(hitInfo); }
else if (hitInfo.collider.name == "plantRightDoor01" || hitInfo.collider.name == "plantRightDoor02" || hitInfo.collider.name == "plantRightDoor03" || hitInfo.collider.name == "plantRightDoor04" || hitInfo.collider.name == "plantRightDoor05" || hitInfo.collider.name == "plantRightDoor06" || hitInfo.collider.name == "plantRightDoor07" || hitInfo.collider.name == "plantRightDoor08")
{
OpenOrCloseRightDoor(hitInfo);
}
}
}
private void OpenOrCloseLeftDoor(RaycastHit hitInfo)
{
leftAnim = hitInfo.collider.transform.GetComponent<Animation>();
if (!storeAnimation.Contains(leftAnim))//说明第一次点击
{
leftAnim["leftDoor"].speed = ;
leftAnim.Play("leftDoor");
storeAnimation.Add(leftAnim);
}
else
{
leftAnim["leftDoor"].time = leftAnim["leftDoor"].length;
leftAnim["leftDoor"].speed = -;
leftAnim.Play("leftDoor");
storeAnimation.Remove(leftAnim);
}
} private void OpenOrCloseRightDoor(RaycastHit hitInfo)
{
rightAnim = hitInfo.collider.transform.GetComponent<Animation>();
if (!storeAnimation.Contains(rightAnim))//说明第一次点击
{
rightAnim["rightDoor"].speed = ;
rightAnim.Play("rightDoor");
storeAnimation.Add(rightAnim);
}
else
{
rightAnim["rightDoor"].time = rightAnim["rightDoor"].length;
rightAnim["rightDoor"].speed = -;
rightAnim.Play("rightDoor");
storeAnimation.Remove(rightAnim);
}
}

unity中多个门的开关动画保持独立性的更多相关文章

  1. 关于Unity中新版动画系统的使用

    Mecanim动画 1:旧版动画系统只能通过代码来控制动画播放,随着动画种类变多,代码复杂度也会增加,同时动画过渡也需要非常繁琐的代码控制,为了让有经验的动画师开发动画,unity推出了针对人物角色的 ...

  2. 骨骼动画的原理及在Unity中的使用

    制作骨骼动画 我们看看这几步操作后,我们得到了那些数据: 1.每个皮肤顶点的初始世界坐标. 2.每个骨骼关节顶点的初始世界坐标. 3.每个顶点被骨骼顶点的影响信息. 4.骨骼如何移动. 骨骼动画原理 ...

  3. 如何在unity中使用龙骨动画

    龙骨 龙骨是Egret公司的一个用来做动画的软件,本文分享一下如何在Unity2D中使用龙骨导出的2D动画 导出动画 在龙骨中文件->导出,导出动画数据和纹理到Unity的项目中,如果打包了的话 ...

  4. 关于Unity中旧版动画系统的使用

    Unity在5.X以后,有一个旧版的动画系统和新版的动画系统. 新版的动画系统是使用Unity动画编辑器来调的,调动画和控制动画 旧版的动画系统是用其他的第三方软件调好后导出到一个FBX文件里面,就是 ...

  5. 高速上手Unity中最好的补间动画插件DFTween

     出处:http://blog.csdn.net/u010019717 author:孙广东      时间:2015.3.17   23:00 DFTween 是一个在 Unity 游戏引擎中高 ...

  6. unity中的动画制作方法

    Unity中的动画制作方法 1.DOTween DoTween在5.0版本中已经用到了,到官网下载好插件之后,然后通过在项目中导入头using DG.Tweening;即可. 一些常用的API函数 D ...

  7. 动画重定向技术分析和Unity中的应用

    http://www.jianshu.com/p/6e9ba1b9c99e 因为一些手游项目需要使用Unity引擎,但在动画部分需要使用重定向技术来实现动画复用,考虑到有些项目开发人员没有过这方面的经 ...

  8. 动画重定向技术分析及其在Unity中的应用

    前言 笔者新的手游项目使用Unity引擎,动画部分要使用重定向技术来实现动画复用.笔者之前在大公司工作的时候对这块了解比较深入,读过Havok引擎在这部分的实现源码,并基于自己的理解,在公司自研的手游 ...

  9. Unity中的资源管理

    一.AssetBundle 相关 Q1:Unity中的SerializedFile是怎么产生的?请问用Unload(false)可以清除吗?因为读取了Bundle里面的内容后已经赋值给其他物体了.而且 ...

随机推荐

  1. python学习之文本文件上传

    最近用python的flask框架完成了一个最基本的文本文件上传,然后读取. 前端用的Angular的ng2-file-upload完成文件上传,后端用flask接收上传的文件,接着做处理. 在交互的 ...

  2. 如何对tcp流认证并加密

    一个场景:目前越来越多的业务需要远程读写Redis,而Redis 本身不提供 SSL/TLS 的支持,在需要安全访问的环境下. 这时候就需要额外的手段进行加密认证,这里有两种手段:spiped 和 n ...

  3. bootstrap 简单练习(后续把其它页面也进行练习)

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  4. Docker 简单部署 ElasticSearch

    https://www.cnblogs.com/jianxuanbing/p/9410800.html

  5. redis序列化

    private void setSerializer(StringRedisTemplate template) { Jackson2JsonRedisSerializer jackson2JsonR ...

  6. 9_grep及正则表达式

    文本查找的需要grep,egrep,fgrep grep:Global Research.根据模式,去搜索文本,并将符合模式的文本行显示出来Pattern:文本字符和正则表达式的元字符组合而成匹配条件 ...

  7. 开发者中心没有勾选 ipad却需要传宣传图片的解决方法

    1.通过模拟器 运行一个ipad 把ipad的比例调到100% 然后保存图片,如果没有适配ipad会出现上下左右黑色边框,这些不必在意,把保存的图片拖到开发者中心即可,勾选右侧 ,都使用12.9英寸图 ...

  8. java异常处理try catch finally

    1       异常 1.1      异常处理的作用 在编程时,如果出现文件打开失败,读写文件就会异常退出.如果出现内存溢出错误,程序也会异常退出.如果不能对这些异常进行处理.程序则无法正常运行.所 ...

  9. python-获取URL中的json数据

    数据源为某系统提供的URL,打开是json文件,python代码获取如下: URL替换成自己的即可. import urllib.request def get_record(url): resp = ...

  10. linux shell 脚本 svn自动更新项目并且打包 、发布、备份

    这里先准备一个配置文件,用于保存svn地址.目的路径.用户名跟密码 配置文件名问:toolConfig.properties #svn地址 svnAddress=https://192.168.1.2 ...