【发布时间】:2017-09-06 15:39:23
【问题描述】:
如何使用 Handheld.Vibrate() 进行一次以上的振动?
【问题讨论】:
-
“称我为愚蠢,但那是 Java 而不是 C#。我问“我可以在 C# 中做类似的事情吗?”” 你可能确实很愚蠢,因为我的回答留在那个帖子上的是 C#,这是做振动模式的正确方法。
如何使用 Handheld.Vibrate() 进行一次以上的振动?
【问题讨论】:
我猜你可以使用 Coroutines 做你想做的事:
void OnGUI()
{
if (GUI.Button(new Rect(0, 10, 100, 32), "Vibrate!"))
StartCoroutine( Vibrate() ) ;
}
private IEnumerator Vibrate()
{
float interval = 0.05f ;
WaitForSeconds wait = new WaitForSeconds(interval);
float t ;
for( t = 0 ; t < 1 ; t += interval ) // Change the end condition (t < 1) if you want
{
Handheld.Vibrate();
yield return wait ;
}
yield return new WaitForSeconds(0.4f);
for( t = 0 ; t < 1 ; t += interval ) // Change the end condition (t < 1) if you want
{
Handheld.Vibrate();
yield return wait ;
}
}
【讨论】: