unity3d - 在编辑器中播放带有开始时间的音频
问题描述
您好我正在尝试在自定义编辑器中播放音频并设置开始采样时间。
public static void PlayClip(AudioClip clip, int startSample = 0, bool loop = false)
{
System.Reflection.Assembly unityEditorAssembly = typeof(AudioImporter).Assembly;
System.Type audioUtilClass = unityEditorAssembly.GetType("UnityEditor.AudioUtil");
System.Reflection.MethodInfo method = audioUtilClass.GetMethod(
"PlayClip",
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public,
null,
new System.Type[] { typeof(AudioClip), typeof(int), typeof(bool) },
null
);
method.Invoke(
null,
new object[] { clip, startSample, loop }
);
}
如果有人知道该怎么做,请帮助我:)
解决方案
推荐阅读
- ios - 为什么 UIImage(data:) 不以压缩文件大小创建图像?
- intellij-idea - 如何使用 apache velocity 声明测试类的字段变量?
- javascript - if语句实时防止负数
- java - 您如何将 BigInteger 与 for 循环和修改 BigIntegers 一起使用?
- c# - 带有标题和内容的 HttpClient PostAsync c#
- c# - 使用 Texture2D 创建平滑圆角矩形
- java - ArrayList - 索引与大小
- django - AWS 弹性 beantalk 上的 Django 项目始终具有“严重”的健康状况和 100% 的 CPU 负载
- javascript - 为什么会触发两个事件侦听器而不是一个?
- regex - sas 子字符串到第一个空格