Unity3d 使用开始时间在编辑器中播放音频
您好,我正在尝试在自定义编辑器中播放音频,并设置开始采样时间Unity3d 使用开始时间在编辑器中播放音频,unity3d,audio,unity-editor,unity3d-editor,Unity3d,Audio,Unity Editor,Unity3d Editor,您好,我正在尝试在自定义编辑器中播放音频,并设置开始采样时间 public static void PlayClip(AudioClip clip, int startSample = 0, bool loop = false) { System.Reflection.Assembly unityEditorAssembly = typeof(AudioImporter).Assembly; System.Type audioUtilClass = unityEditorAsse
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 }
);
}
如果有人知道怎么做,请帮助我:)大概你当前的代码不工作了?发生了什么事?@PhilippLenssen Yeah:)除了startSample之外,一切都正常……不管它的价值是什么,这首歌总是从一开始就开始。我在一些论坛上发现更多人有相同的问题和相同的代码,但似乎只有一个人知道解决方案,但我无法理解@PhilippLenssen如果你知道如何解决这个问题,请帮助我。我正在工作的编辑器扩展,我真的需要这个功能。如果我找不到解决方案,我将不得不更改大量代码,并在播放模式下使用扩展。如果你能帮我,这对我来说意义重大:)