1 Star 0 Fork 3

wayfarer/rongYaoDaLuCode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
EffectMono.cs 1.85 KB
一键复制 编辑 原始数据 按行查看 历史
liyonghelpme 提交于 2015-05-19 23:14 +08:00 . rong Yao Da Lu Some Code For Game
using System;
using UnityEngine;
public class EffectMono : MonoBehaviour
{
public bool isLoop;
public bool isNeedMirror;
[HideInInspector]
public byte launcherForce;
private float lifeTime;
public float LifeTime;
private float timeCount;
private float getLifeTime()
{
float length = 0f;
foreach (ParticleSystem system in base.gameObject.GetComponentsInChildren<ParticleSystem>())
{
if (system.isPlaying && (length < (system.duration + system.startLifetime)))
{
length = system.duration + system.startLifetime;
}
}
Animation[] componentsInChildren = base.gameObject.GetComponentsInChildren<Animation>();
if (componentsInChildren.Length > 0)
{
foreach (Animation animation in componentsInChildren)
{
if (((animation.clip != null) && animation.isPlaying) && (length < animation.clip.length))
{
length = animation.clip.length;
}
}
}
return length;
}
private void Start()
{
if (this.isNeedMirror && (this.launcherForce == 1))
{
base.transform.localScale = new Vector3(-1f, 1f, 1f);
}
if (!this.isLoop)
{
this.lifeTime = this.LifeTime;
if (this.lifeTime <= 0f)
{
this.lifeTime = this.getLifeTime();
}
}
}
private void Update()
{
if (!this.isLoop)
{
this.timeCount += Time.deltaTime;
if (this.timeCount > this.lifeTime)
{
this.isLoop = true;
UnityEngine.Object.DestroyImmediate(base.gameObject);
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wayfarer/rongYaoDaLuCode.git
git@gitee.com:wayfarer/rongYaoDaLuCode.git
wayfarer
rongYaoDaLuCode
rongYaoDaLuCode
master

搜索帮助