位置: 编程技术 - 正文

unity3d特效延迟播放的脚本问题(unity延迟调用函数)

编辑:rootadmin

推荐整理分享unity3d特效延迟播放的脚本问题(unity延迟调用函数),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:unity 延迟,unity延迟调用函数,unity 延迟,unity3d 特效,unity3d 特效,unity 延迟,unity延迟渲染,unity音效延迟,内容如对您有帮助,希望把文章链接给更多的朋友!

特效很多情况下需要延迟播放,当然你可以直接在特效编辑的时候就有delay的时间设置,但有些时候我们需要自己控制这个时间。

比如人物pause的时候,你如果不用代码控制,那么特效就直接播放出来了。

普通的delay脚本不通用,很多情况下无法处理。

unity3d特效延迟播放的脚本问题(unity延迟调用函数)

我写了一个比较通用的写法:

using UnityEngine;using System.Collections;using System;public class Delay : MonoBehaviour { public float delayTime = 1.0f; // Use this for initialization Charactor player; bool flag = false; long timeId; bool isDone = false; public bool checkIsDone() { return isDone; } public void resetFlag() { flag = false; } Delay[] delayArr = null; void OnEnable() { if(flag) { flag = false; return; } if(delayArr == null) { delayArr = GetComponentsInParent<Delay> (); } for(int i = 0; i < delayArr.Length; i&#;&#;) { if(delayArr[i] == this) { continue; } if(!delayArr[i].checkIsDone()) { return; } } flag = true; player = GameObjectUtil.getCharactorFromObj (gameObject); if(player == null) { return; } gameObject.SetActive (false); //gameObject.SetActiveRecursively(false); CharactorTimer timer = player.timer; timeId = timer.TimeOut (delayTime, DelayFunc, new Hashtable ()); player.addActionEffectDelayTimerId (timeId, this); } void DelayFunc(Hashtable param) { player.removeActionEffectDelayTimerId (timeId, this); timeId = 0; isDone = true; gameObject.SetActive (true); //gameObject.SetActiveRecursively(true); } void OnDisable() { isDone = false; }}

当然你会看到一些奇怪的东西,无须在意,只是大致上的思路如此。

Unity3d 调用 C++ DLL之 DLL回调Unity3d (C++ DLL回调 C#函数) 上篇Unity3d调用CDLL(Win平台)介绍了简单的Unity3d调用CDLL的方法,但是这样是不够的,这里再讲下通过函数指针让CDLL中回调Unity3d的方式。转自

Unity3D坐标转换 转载自:

Unity3d 调用 Luajit C++ DLL 实现调用 Lua脚本 前面介绍了在Unity3d中通过Plugin功能来调用CDLL中的函数以及回调的使用方法,但最终目的还是让Unity3d中可以调用Lua脚本中的函数,现在来实现。首先关

本文链接地址:https://www.jiuchutong.com/biancheng/377196.html 转载请保留说明!

上一篇:AddForceAtPosition方法:增加刚体点作用力

下一篇:Unity3d 调用 C++ DLL之 DLL回调Unity3d (C++ DLL回调 C#函数)(unity3d c++开发)

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络