UrhoEngine.cs 830 B

123456789101112131415161718192021222324252627282930
  1. using System.Linq;
  2. using System.Runtime.InteropServices;
  3. using Foundation;
  4. namespace Urho.iOS
  5. {
  6. public static class UrhoEngine
  7. {
  8. [DllImport("mono-urho")]
  9. static extern void InitSdl(string resDir, string docDir);
  10. [DllImport("mono-urho", CallingConvention = CallingConvention.Cdecl)]
  11. static extern void SDL_SetMainReady();
  12. public static void Init()
  13. {
  14. string docs = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.All, true).FirstOrDefault();
  15. string resources = NSBundle.MainBundle.ResourcePath;
  16. Init(resources, docs);
  17. }
  18. public static void Init(string resourcesDir, string docsDir)
  19. {
  20. Application.EngineInited = true;
  21. InitSdl(resourcesDir, docsDir);
  22. SDL_SetMainReady();
  23. NSFileManager.DefaultManager.ChangeCurrentDirectory(resourcesDir);
  24. }
  25. }
  26. }