AssetLoader.cs 967 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using BepInEx.Common;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Text;
  7. using UnityEngine;
  8. namespace ResourceRedirector
  9. {
  10. public static class AssetLoader
  11. {
  12. public static AudioClip LoadAudioClip(string path, AudioType type)
  13. {
  14. using (WWW loadGachi = new WWW(Utility.ConvertToWWWFormat(path)))
  15. {
  16. AudioClip clip = loadGachi.GetAudioClipCompressed(false, type);
  17. //force single threaded loading instead of using a coroutine
  18. while (!clip.isReadyToPlay) { }
  19. return clip;
  20. }
  21. }
  22. public static Texture2D LoadTexture(string path)
  23. {
  24. byte[] data = File.ReadAllBytes(path);
  25. Texture2D tex = new Texture2D(2, 2);
  26. //DDS method
  27. //tex.LoadRawTextureData
  28. tex.LoadImage(data);
  29. return tex;
  30. }
  31. }
  32. }