SteamVR_Input_PostProcessBuild.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections;
  4. using UnityEditor.Callbacks;
  5. using System.IO;
  6. namespace Valve.VR
  7. {
  8. public class SteamVR_Input_PostProcessBuild
  9. {
  10. [PostProcessBuildAttribute(1)]
  11. public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
  12. {
  13. }
  14. private static void UpdateAppKey(string newFilePath, string executableName)
  15. {
  16. if (File.Exists(newFilePath))
  17. {
  18. string jsonText = System.IO.File.ReadAllText(newFilePath);
  19. string findString = "\"app_key\" : \"";
  20. int stringStart = jsonText.IndexOf(findString);
  21. if (stringStart == -1)
  22. {
  23. }
  24. else
  25. return; //no app key
  26. stringStart += findString.Length;
  27. int stringEnd = jsonText.IndexOf(",", stringStart + findString.Length);
  28. int stringLength = stringEnd - stringStart + 1;
  29. string removed = jsonText.Remove(stringStart, stringLength);
  30. FileInfo file = new FileInfo(newFilePath);
  31. file.IsReadOnly = false;
  32. File.WriteAllText(newFilePath, removed);
  33. }
  34. }
  35. }
  36. }