IosPlatformInitializer.cs 731 B

123456789101112131415161718192021222324
  1. using System.Linq;
  2. using System.Runtime.InteropServices;
  3. using Foundation;
  4. namespace Urho.iOS
  5. {
  6. public static class IosUrhoInitializer
  7. {
  8. [DllImport(Consts.NativeImport)]
  9. static extern void InitSdl(string resDir, string docDir);
  10. [DllImport(Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  11. static extern void SDL_SetMainReady();
  12. internal static void OnInited()
  13. {
  14. string docsDir = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.All, true).FirstOrDefault();
  15. string resourcesDir = NSBundle.MainBundle.ResourcePath;
  16. InitSdl(resourcesDir, docsDir);
  17. SDL_SetMainReady();
  18. NSFileManager.DefaultManager.ChangeCurrentDirectory(resourcesDir);
  19. }
  20. }
  21. }