让这段代码,receivedGesture == "guqin"判断的对象字符串可以在脚本外输入变化控制,不局限于guqin,给出修改后的代码if ((condition == "WAITING_GESTURE") && receivedGesture == "guqin") { //Input.GetKey(KeyCode.Space // 人物运动,播放音乐 player.GetComponent<VideoPlayer>().Play(); player.GetComponent<AudioSource>().Play(); // 粒子出现 particle.SetActive(true); condition = "NEXT"; timer = 0; }
时间: 2024-02-14 11:30:03 浏览: 23
你可以通过将字符串变量作为输入参数传递给代码来实现你想要的控制。修改后的代码如下:
```csharp
if (condition == "WAITING_GESTURE" && receivedGesture == userInput) {
// 人物运动,播放音乐
player.GetComponent<VideoPlayer>().Play();
player.GetComponent<AudioSource>().Play();
// 粒子出现
particle.SetActive(true);
condition = "NEXT";
timer = 0;
}
```
在这段代码中,我添加了一个名为 `userInput` 的变量,它用于存储用户输入的字符串。你可以通过在脚本外部设置 `userInput` 的值来改变判断的对象字符串。