UrhoSurface.cs 756 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using CoreGraphics;
  4. using UIKit;
  5. namespace Urho.iOS
  6. {
  7. public class UrhoSurface : UIView
  8. {
  9. [DllImport("mono-urho", CallingConvention = CallingConvention.Cdecl)]
  10. static extern void SDL_SetExternalViewPlaceholder(IntPtr viewPtr, IntPtr windowPtr);
  11. public UrhoSurface()
  12. {
  13. BackgroundColor = UIColor.Black;
  14. }
  15. public UrhoSurface(CGRect frame) : base(frame)
  16. {
  17. BackgroundColor = UIColor.Black;
  18. }
  19. public override void WillMoveToWindow(UIWindow window)
  20. {
  21. if (!Application.EngineInited)
  22. {
  23. UrhoEngine.Init(); //just in case if user forgot to call it.
  24. }
  25. SDL_SetExternalViewPlaceholder(Handle, window?.Handle ?? IntPtr.Zero);
  26. base.WillMoveToWindow(window);
  27. }
  28. }
  29. }