Skip to content

Instantly share code, notes, and snippets.

@wavebit
Last active September 10, 2018 16:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wavebit/e579cafb5084253a990d0502d5e466a7 to your computer and use it in GitHub Desktop.
Save wavebit/e579cafb5084253a990d0502d5e466a7 to your computer and use it in GitHub Desktop.
Wwise ID Converter #Wwise
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