- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在为我的 UI 元素制作一个简单的动画。
我有一个动画组件,它有 2 个不同的动画 - ZoomIn 和 ZoomOut。
每当需要在屏幕上显示 UI 元素(例如按钮)时,就会显示这些动画。
我通常更喜欢在不显示时停用游戏对象。
我为动画编写了以下方法:
私有(private) IEnumerator ToggleObjectWithAnimation (GameObject gameObj) {
动画师 gameObjectAnimator = gameObj.GetComponent();//Animator 设置为未缩放时间
如果(gameObj.activeSelf == false){
gameObj.transform.localScale = new Vector3 (0, 0, 1.0f);
gameObj.SetActive (true);
gameObjectAnimator.SetTrigger ("ZoomIn");
yield return new WaitForSeconds (0.5f);
} 否则如果(gameObj.activeSelf == true){
gameObjectAnimator.SetTrigger ("ZoomOut");
yield return new WaitForSeconds (0.5f);
gameObj.SetActive (false);//当 timescale = 0 时代码不执行
}
yield 返回空;
}
该代码在大多数屏幕上都可以正常工作,但是当我使用 timescale = 0 暂停游戏时会出现问题。
当 timescale 为 0 时,gameObj.SetActive (false) 行不起作用。
最佳答案
我知道可能有点晚了,但是:
问题不在于 SetActive
但是那个 WaitForSeconds
si 受 Time.timeScale
影响!
The actual time suspended is equal to the given time multiplied by
Time.timeScale
. SeeWaitForSecondsRealtime
if you wish to wait using unscaled time.
Time.timescale=0
WaitForSeconds
永远不会完成!
WaitForSecondsRealtime
private IEnumerator ToggleObjectWithAnimation (GameObject gameObj)
{
Animator gameObjectAnimator = gameObj.GetComponent (); // Animator is set to unscaled time
if (gameObj.activeSelf == false)
{
gameObj.transform.localScale = new Vector3 (0, 0, 1.0f);
gameObj.SetActive (true);
gameObjectAnimator.SetTrigger ("ZoomIn");
yield return new WaitForSecondsRealtime(0.5f);
}
else if(gameObj.activeSelf == true)
{
gameObjectAnimator.SetTrigger ("ZoomOut");
yield return new WaitForSecondsRealtime(0.5f);
gameObj.SetActive (false); // code not execute when timescale = 0
}
yieldr eturn null;
}
关于c# - 受 timeScale 影响的协程 WaitForSeconds,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36110448/
所有以字符 ` 开头的 Verilog 代码行似乎都是预处理器指令。然而,`timescale 似乎有点奇怪,也许吧。 `timescale 是预处理器指令吗?如果是,它被什么取代了? 最佳答案 在
我正在使 X 轴显示年份。但是它不起作用,我的 cx 值为 0。我的猜测是 d3.timeFormat 解析年份值出现问题。 //d3.format year as yyyy let dateForm
我正在为我的 UI 元素制作一个简单的动画。 我有一个动画组件,它有 2 个不同的动画 - ZoomIn 和 ZoomOut。 每当需要在屏幕上显示 UI 元素(例如按钮)时,就会显示这些动画。 我通
let assetItem = AVAsset(URL: NSURL(fileURLWithPath: "videofile")); let timescale = assetItem.duratio
我有一个脚本,在 CollisionEnter2D 上,粒子从一个对象发射,游戏暂停。粒子也停止了。但我不想暂停粒子。我希望他们即使在比赛暂停时也能继续比赛。我该怎么做? 这是一个脚本: using
我正在尝试让 fmp4 HLS 在新的 Chromecast(我相信第三代,而不是 Ultra)上播放。 我尝试使用 x264 和 h264 库使用 ffmpeg 对内容进行编码。 主要配置文件最初给
我有一个包含两个时间列的 Timescale 时间序列表:itime和 stime对应插入时间和源时间。 我在 stime 上创建了 Timescale hypertable因为所有评估都将在源时间进
脚本附加到空游戏对象: using System.Collections; using System.Collections.Generic; using UnityEngine; public cl
我目前正在制作一个游戏,我在其中使用 GetAxis 来移动。在这个游戏中经常发生的事情是时间减慢到大约 20%,这会导致奇怪的行为。 GetAxis 和 GetAxisRaw 之间的区别在于 Get
我正在尝试找到一种在不使用“Time.timeScale = 0;”的情况下在 Unity 中暂停我的游戏的方法。我想改变这个的原因是我想让角色在游戏暂停时播放动画。有没有办法更改此脚本,使重力和前进
我正在尝试使用 DOTween 的缓动函数来制作 Time.timescale 动画。 补间值本身似乎有效: DG.Tweening.DOTween.To(value => Time.timeScal
我用 创建了一个数据管道Apache Ni-Fi (版本 1.15.2)将数据从 AWS RDS 实例中的 MySQL 数据库传输到 Timescale (postgreSQL)。 Ni-Fi 在 W
我有一个 Timescale DB 正在运行并且正在使用 JOOQ 来访问数据。 我正在使用 gapfill()为了 dslContext .select(Routines.timeB
我想在游戏暂停时使用 TrailRenderer,但由于 timeScale 为 0,因此产生的 deltaTime 为 0,这导致 TrailRenderer 无法运行(尾部永远不会消失) 我找不到
我是一名优秀的程序员,十分优秀!