[MenuItem("将所有3D音效改成2D音效")]
static void change3DMusicTo2D()
{
string[] fs = GetSoundMetaFile();
bool hasChangeFile = false;
foreach(var f in fs)
{
if(MakeSoundMetaFile3DFalse(f))
{
hasChangeFile = true;
}
}
if(hasChangeFile)
AssetDatabase.Refresh();
}
static string[] GetSoundMetaFile()
{
string dir = Application.dataPath + "/Resources/Res/Audio/";
return System.IO.Directory.GetFiles(dir,"*.ogg.meta",System.IO.SearchOption.AllDirectories);
}
static bool MakeSoundMetaFile3DFalse(string file)
{
var text = System.IO.File.ReadAllText(file);
int pos = text.IndexOf("3D: 1");
if(pos > 0)
{
text = text.Replace("3D: 1","3D: 0");
System.IO.File.WriteAllText(file,text);
Debug.Log(string.Format("Sound File Make 3D False:{0}",file);
return true;
}
return false;
}
原文地址:https://linxinfa.blog.csdn.net
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。