diff --git a/.github/latest.md b/.github/latest.md index d6b9498..062d3c1 100644 --- a/.github/latest.md +++ b/.github/latest.md @@ -1,4 +1,5 @@ ## Changelog -- update install description +### Fixed +- update IOS build processor to include WebKit framework in [#37](https://github.com/readyplayerme/rpm-unity-sdk-webview/pull/37) diff --git a/CHANGELOG.md b/CHANGELOG.md index 171af9b..05bff7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [2.2.1] - 2024.25.04 + +### Fixed +- feat: update install description by @rk132 in [#37](https://github.com/readyplayerme/rpm-unity-sdk-webview/pull/37) + ## [2.2.0] - 2024.24.01 ### Updated diff --git a/Editor/IOSBuildProcessor.cs b/Editor/IOSBuildProcessor.cs index 1143c18..c847d5d 100644 --- a/Editor/IOSBuildProcessor.cs +++ b/Editor/IOSBuildProcessor.cs @@ -1,30 +1,63 @@ #if UNITY_IOS +using System; using System.IO; +using UnityEditor.Callbacks; using UnityEditor; -using UnityEditor.Build; -using UnityEditor.Build.Reporting; -using UnityEditor.iOS.Xcode; +using UnityEngine; namespace ReadyPlayerMe.WebView.Editor { - public class IOSBuildProcessor : IPostprocessBuildWithReport + public class IOSBuildProcessor { - public int callbackOrder => 0; - public void OnPostprocessBuild(BuildReport report) + [PostProcessBuild(100)] + public static void OnPostprocessBuild(BuildTarget buildTarget, string path) { - if (report.summary.platform != BuildTarget.iOS) return; + if (buildTarget != BuildTarget.iOS) return; - var projectPath = $"{report.summary.outputPath}/Unity-iPhone.xcodeproj/project.pbxproj"; + var projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj"; + var type = Type.GetType("UnityEditor.iOS.Xcode.PBXProject, UnityEditor.iOS.Extensions.Xcode"); + if (type == null) + { + Debug.LogError("unitywebview: failed to get PBXProject. please install iOS build support."); + return; + } + var src = File.ReadAllText(projPath); + var proj = type.GetConstructor(Type.EmptyTypes).Invoke(null); + { + var method = type.GetMethod("ReadFromString"); + method.Invoke(proj, new object[] { src }); + } + var target = ""; + { + var method = type.GetMethod("GetUnityFrameworkTargetGuid"); + target = (string) method.Invoke(proj, null); + } - var pbxProject = new PBXProject(); - pbxProject.ReadFromFile(projectPath); - - // Main - var targetGuid = pbxProject.GetUnityMainTargetGuid(); - pbxProject.AddFrameworkToProject(targetGuid, "WebKit.framework", false); - - pbxProject.WriteToFile(projectPath); + { + var method = type.GetMethod("AddFrameworkToProject"); + method.Invoke(proj, new object[] { target, "WebKit.framework", false }); + } + var cflags = ""; + if (EditorUserBuildSettings.development) + { + cflags += " -DUNITYWEBVIEW_DEVELOPMENT"; + } +#if UNITYWEBVIEW_IOS_ALLOW_FILE_URLS + cflags += " -DUNITYWEBVIEW_IOS_ALLOW_FILE_URLS"; +#endif + cflags = cflags.Trim(); + if (!string.IsNullOrEmpty(cflags)) + { + var method = type.GetMethod("AddBuildProperty", new Type[] { typeof(string), typeof(string), typeof(string) }); + method.Invoke(proj, new object[] { target, "OTHER_CFLAGS", cflags }); + } + var dst = ""; + { + var method = type.GetMethod("WriteToString"); + dst = (string) method.Invoke(proj, null); + } + File.WriteAllText(projPath, dst); } } } diff --git a/Runtime/WebViewPanel.cs b/Runtime/WebViewPanel.cs index 13f5da6..1665df4 100644 --- a/Runtime/WebViewPanel.cs +++ b/Runtime/WebViewPanel.cs @@ -3,6 +3,7 @@ using ReadyPlayerMe.Core; using ReadyPlayerMe.Core.WebView; using UnityEngine; +using UnityEngine.Events; namespace ReadyPlayerMe.WebView { @@ -23,6 +24,8 @@ public class WebViewPanel : MonoBehaviour [SerializeField] public WebViewEvent OnUserSet = new WebViewEvent(); [SerializeField] public WebViewEvent OnUserAuthorized = new WebViewEvent(); [SerializeField] public AssetUnlockEvent OnAssetUnlock = new AssetUnlockEvent(); + [SerializeField] public UnityEvent OnUserLogout = new UnityEvent(); + [SerializeField] public WebViewEvent OnUserUpdate = new WebViewEvent(); private WebViewBase webViewObject = null; @@ -155,6 +158,12 @@ private void HandleEvents(WebMessage webMessage) case WebViewEvents.USER_AUTHORIZED: OnUserAuthorized?.Invoke(webMessage.GetUserId()); break; + case WebViewEvents.USER_LOGOUT: + OnUserLogout?.Invoke(); + break; + case WebViewEvents.USER_UPDATED: + OnUserUpdate?.Invoke(webMessage.GetUserId()); + break; } } diff --git a/package.json b/package.json index bb01939..c4b48d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.readyplayerme.webview", - "version": "2.2.0", + "version": "2.2.1", "displayName": "Ready Player Me WebView", "description": "Ready Player Me WebView helps you display an in-engine browser that helps you load RPM website where you can create avatars and receive avatar URL at the end of the process.\nWebView is mobile only and works in Android and IOS builds.", "category": "tool",