Last active
September 10, 2018 16:34
-
-
Save wavebit/e579cafb5084253a990d0502d5e466a7 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.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", "namcespace AKID"); | |
tmpLine = tmpLine.Replace("static const AkUniqueID", "public const uint"); | |
outputLines.Add(tmpLine); | |
} | |
} | |
outputLines[0] = "namespace AKID"; | |
System.IO.File.WriteAllLines(outputFilePath, outputLines, new UTF8Encoding(true)); | |
} | |
[MenuItem("Tool/ConvertWwiseIDs")] | |
public static void Convert() | |
{ | |
var inputFilePath = Application.dataPath + "\\StreamingAssets\\Audio\\GeneratedSoundBanks\\Wwise_IDs.h"; | |
var outputFilePath = Application.dataPath + "\\Wwise\\Wwise_IDs.cs"; | |
Convert(inputFilePath, outputFilePath); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment