显示对象在Unity3D几毫秒 [英] Display an object for a few milliseconds in Unity3D

查看:1812
本文介绍了显示对象在Unity3D几毫秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Unity3D设置一个实验(大学相关),在那里我设计了一个迷宫,用户收到潜意识提示(屏幕上显示的视觉箭头),应该只出现14毫秒,然后消失。 >

我已经设计了3D迷宫,它真的是最小的(我不需要任何花哨的实验),因此我可以实现1000fps当我导航与第一人称控制器(帧率不会是一个问题)。我计划在C#中编写一个脚本,以便在触发某些对象时显示这些箭头。



我想知道在Unity中是否可以显示对象毫秒(在我的情况下,14ms)与可接受的精度...如果是这样,我应该使用哪种方法?

解决方案

任何想法或以前有类似问题的经验者。



<

使用协程只显示对象的时间:

  void * AnyTrigger *如果使用触发器,请用OnTriggerEnter替换
{
StartCoroutine(ShowObject(14f / 1000f));
}

IEnumerator ShowObject(float timeInSeconds)
{
//此处显示对象
yield return WaitForSeconds(timeInSeconds);
//隐藏物件
}



精确度



显示对象的时间的精确度主要取决于您使用的系统。如果你在一个快速的系统上运行Unity3D,它可能是非常准确的。



示例(不准确): b


  • 快速系统,每秒950-1000帧:喜欢在0ms和1ms之间

  • 中型系统,每秒300-600帧:很可能在0.8ms到3.6ms之间

  • 慢速系统,每秒50-100帧:最好在5ms和20ms之间


I'm using Unity3D to setup an "experiment" (university related) where I designed a maze and users receive subliminal cues (visual arrows displayed on the screen) that should appear just for 14 milliseconds and then disappear.

I already designed the 3D maze and it's really minimal (I don't need anything fancy for the experiment), therefore I can achieve 1000fps when I navigate with a 1st person controller into it (the framerate won't be a problem). I'm planning to program a script in C# to display these arrows when some objects are triggered.

I'm wondering if in Unity it's possible to display objects just for some milliseconds (in my case, 14ms) with an acceptable accuracy... If so, which approach should I use? Any ideas or previous experiece with similar issues?

Thank you in advance

解决方案

Use coroutines to display objects just a amount of time:

void *AnyTrigger*() // eg. replace with OnTriggerEnter if using triggers
{
    StartCoroutine(ShowObject(14f / 1000f));
}

IEnumerator ShowObject(float timeInSeconds)
{
    // Show object here
    yield return new WaitForSeconds(timeInSeconds);
    // Hide object
}

Accuracy

The accuarcy of the time in which the object is shown depends highly on the system which you are using. If you are running Unity3D on a fast system it might be very accurate. If the system is slow the time is very likly to be over 14ms.

Examples( not accurate ):

  • Fast system, 950-1000 frames per second: Likly between 0ms and 1ms
  • Medium system, 300-600 frames per second: Likly between 0.8ms and 3.6ms
  • Slow system, 50-100 frames per second: Likly between 5ms and 20ms

这篇关于显示对象在Unity3D几毫秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆