MacBuildScript.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright (c) 2022 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_STANDALONE_OSX
  15. #pragma warning disable CS0618
  16. using System;
  17. using System.IO;
  18. using UnityEngine;
  19. using UnityEditor;
  20. using UnityEditor.Build;
  21. using UnityEditor.Callbacks;
  22. using UnityEngine.Rendering;
  23. using Vuplex.WebView.Internal;
  24. namespace Vuplex.WebView.Editor {
  25. public class MacBuildScript : IPreprocessBuild {
  26. public int callbackOrder { get { return 0; } }
  27. public void OnPreprocessBuild(BuildTarget buildTarget, string buildPath) {
  28. if (buildTarget != BuildTarget.StandaloneOSX) {
  29. return;
  30. }
  31. #if !VUPLEX_DISABLE_GRAPHICS_API_WARNING
  32. var selectedGraphicsApi = PlayerSettings.GetGraphicsAPIs(buildTarget)[0];
  33. var error = VXUtils.GetGraphicsApiErrorMessage(selectedGraphicsApi, new GraphicsDeviceType[] { GraphicsDeviceType.Metal });
  34. if (error != null) {
  35. throw new BuildFailedException(error);
  36. }
  37. #endif
  38. }
  39. [PostProcessBuild(700)]
  40. public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject) {
  41. if (target != BuildTarget.StandaloneOSX) {
  42. return;
  43. }
  44. // Delete all of the .meta files added by Unity because they cause a codesign mismatch
  45. // which causes app notarization to fail.
  46. var metaFiles = Directory.GetFiles(pathToBuiltProject, "*.meta", SearchOption.AllDirectories);
  47. foreach (var file in metaFiles) {
  48. File.Delete(file);
  49. }
  50. }
  51. }
  52. }
  53. #endif