VXWebViewAppController.mm 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * Copyright (c) 2021 Vuplex Inc. All rights reserved.
  3. *
  4. * Licensed under the Vuplex Commercial Software Library License, you may
  5. * not use this file except in compliance with the License. You may obtain
  6. * a copy of the License at
  7. *
  8. * https://vuplex.com/commercial-library-license
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "IUnityGraphicsMetal.h"
  17. #import "VXWebViewAppController.h"
  18. static IUnityGraphicsMetal *_metalGraphics = nullptr;
  19. static void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API VuplexUnityPluginLoad(IUnityInterfaces* unityInterfaces) {
  20. _metalGraphics = unityInterfaces->Get<IUnityGraphicsMetal>();
  21. }
  22. static void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API VuplexUnityPluginUnload() {}
  23. @implementation VXWebViewAppController
  24. - (void)shouldAttachRenderDelegate {
  25. // These function names are prefixed with "Vuplex" to prevent them
  26. // from clashing with symbols from other 3rd party plugins.
  27. UnityRegisterRenderingPluginV5(&VuplexUnityPluginLoad, &VuplexUnityPluginUnload);
  28. // Call the base class's `shouldAttachRenderDelegate` implementation in case
  29. // VXWebViewAppController is modified to subclass another plugin's app controller.
  30. [super shouldAttachRenderDelegate];
  31. }
  32. + (id<MTLDevice>)metalDevice {
  33. if (!_metalGraphics) {
  34. NSLog(@"ERROR: VXWebViewAppController._metalGraphics is not set, which means another iOS graphics plugin is clashing with 3D WebView. Please see https://support.vuplex.com/articles/ios-graphics-plugin-conflict");
  35. }
  36. // If you experience an EXC_BAD_ACCESS error here, please see
  37. // https://support.vuplex.com/articles/ios-graphics-plugin-conflict
  38. return _metalGraphics->MetalDevice();
  39. }
  40. @end
  41. IMPL_APP_CONTROLLER_SUBCLASS(VXWebViewAppController);