CanvasWebViewPrefab.WebGL.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright (c) 2024 Vuplex Inc. All rights reserved.
  2. //
  3. // Licensed under the Vuplex Commercial Software Library License, you may
  4. // not use this file except in compliance with the License. You may obtain
  5. // a copy of the License at
  6. //
  7. // https://vuplex.com/commercial-library-license
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #if UNITY_WEBGL && !VUPLEX_DOCS
  15. using System;
  16. using UnityEngine;
  17. using Vuplex.WebView.Internal;
  18. namespace Vuplex.WebView {
  19. partial class CanvasWebViewPrefab {
  20. partial void OnInit() {
  21. if (_canvas != null && _canvas.renderMode == RenderMode.WorldSpace) {
  22. throw new InvalidOperationException("2D WebView for WebGL only supports Native 2D Mode, which requires that the Canvas's render mode be set to \"Screen Space - Overlay\" or \"Screen Space - Camera\", but its render mode is instead currently set to \"World Space\". Please change the Canvas's render mode to \"Screen Space - Overlay\" or \"Screen Space - Camera\".");
  23. }
  24. if (!Native2DModeEnabled) {
  25. Native2DModeEnabled = true;
  26. WebViewLogger.LogWarning("2D WebView for WebGL only supports Native 2D Mode, so CanvasWebViewPrefab.Native2DModeEnabled was automatically set to true.");
  27. }
  28. }
  29. }
  30. }
  31. #endif