c# - Naudio + Unity:如何访问 DeviceCount
问题描述
我想做一个非对称游戏(VR/Gamepad)。所以我需要一些来自电视和 VR 耳机的声音。
我已经安装了 Naudio 插件以实现统一,但我无法使用此版本访问 DeviceCount 属性。然后,我尝试了普通版本。我可以访问该属性,但 Unity3D 在我对脚本进行更改后总是崩溃。
这是我使用常规 Naudio 版本的代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using NAudio;
using NAudio.Wave;
public class Naudio : MonoBehaviour
{
WaveOut waveOut;
WaveFileReader waveReader;
// Start is called before the first frame update
void Start()
{
waveOut = new WaveOut();
Debug.Log("NAUDIO device " + waveOut.DeviceNumber);
Debug.Log("NAUDIO Count " + WaveOut.DeviceCount);
for (int i = -1; i < WaveOut.DeviceCount; i++)
{
var caps = WaveOut.GetCapabilities(i);
Debug.Log("Device Name: " + caps.ProductName);
}
waveOut = new WaveOut();
waveReader = new WaveFileReader("Assets/_Projet/Resources/Sounds/PowerUp.wav");
waveOut.DeviceNumber = -1;
waveOut.Init(waveReader);
waveOut.Play();
}
}
我可以在没有统一崩溃的情况下安装 Naudio,还是我唯一的选择是 Naudio-unity?
谢谢
解决方案
推荐阅读
- firebase - 默认禁用 Firebase 分析
- swift - 扩展 UIView 时出现奇怪的动画
- spring - Spring Security - SPA OpenID 隐式流
- php - 无法打开 PHPexcel.php
- javascript - 时刻语言环境不起作用 - 用英语获取值
- javascript - MongoDB使用参数进行嵌套位置
- python - 如何使用 Python3 从 Centos 连接到 windows 2012 机器
- javascript - 是否可以创建一个值是具有动态属性名称的对象的 ES6 Javascript 表达式?
- javascript - Object.forEach polyfill 在 IE 上不起作用
- angular - 在 Angular 2 中修改 NPM 包的最佳实践