-
-
Save StewMcc/50576a0e471134f6658e463d17bff6ca to your computer and use it in GitHub Desktop.
Wwise ID Converter #Wwise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Text; | |
using UnityEditor; | |
using UnityEngine; | |
internal class WwiseIDConverter { | |
private enum State { | |
Init, | |
Replacing, | |
} | |
public static void Convert(string inputFilePath, string outputFilePath) { | |
var lines = System.IO.File.ReadAllLines(inputFilePath, new UTF8Encoding(false)); | |
List<string> outputLines = new List<string>(); | |
State state = State.Init; | |
foreach (var line in lines) { | |
var tmpLine = line; | |
if (state == State.Init) { | |
if (tmpLine.Contains("namespace")) | |
state = State.Replacing; | |
} | |
if (tmpLine.Contains("#endif")) { | |
break; | |
} | |
if (state == State.Replacing) { | |
tmpLine = tmpLine.Replace("namespace", "public class"); | |
tmpLine = tmpLine.Replace("public class AK", "namespace AKID"); | |
tmpLine = tmpLine.Replace("static const AkUniqueID", "public const uint"); | |
outputLines.Add(tmpLine); | |
} | |
} | |
outputLines[0] = "namespace AKID"; | |
System.IO.File.WriteAllLines(outputFilePath, outputLines.ToArray(), new UTF8Encoding(true)); | |
AssetDatabase.SaveAssets(); | |
AssetDatabase.Refresh(); | |
Debug.Log("New Wwise_IDs.cs Created: " + outputFilePath); | |
} | |
[MenuItem("Tools/ConvertWwiseIDs")] | |
public static void Convert() { | |
var inputFilePath = Application.dataPath + | |
Path.DirectorySeparatorChar + "StreamingAssets" + | |
Path.DirectorySeparatorChar + "Audio" + | |
Path.DirectorySeparatorChar + "GeneratedSoundBanks" + | |
Path.DirectorySeparatorChar + "Wwise_IDs.h"; | |
var outputFilePath = Application.dataPath + | |
Path.DirectorySeparatorChar + "Wwise" + | |
Path.DirectorySeparatorChar + "Wwise_IDs.cs"; | |
Convert(inputFilePath, outputFilePath); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment