Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support to macOS editor play scene #95

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions sample/Assets/Scripts/UnauthenticatedScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async void Start()
#endif

passport = await Passport.Init(
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
clientId, environment, redirectUri, 10000
#else
clientId, environment, redirectUri
Expand Down Expand Up @@ -86,7 +86,8 @@ public async void Connect()
ShowOutput("Called Connect()...");
connectButton.gameObject.SetActive(false);

#if UNITY_ANDROID || UNITY_IPHONE || UNITY_STANDALONE_OSX
// macOS editor (play scene) does not support deeplinking
#if UNITY_ANDROID || UNITY_IPHONE || (UNITY_STANDALONE_OSX && !UNITY_EDITOR_OSX)
await passport.ConnectPKCE();
#else
await passport.Connect();
Expand Down
7 changes: 4 additions & 3 deletions src/Packages/Passport/Runtime/Scripts/Public/Passport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private Passport()
/// <param name="redirectUri">(Currently, mobile only) The URL to which auth will redirect the browser after authorisation has been granted by the user</param>
/// <param name="engineStartupTimeoutMs">(Windows only) Timeout time for waiting for the engine to start (in milliseconds)</param>
public static UniTask<Passport> Init(
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
string clientId, string environment, string? redirectUri = null, int engineStartupTimeoutMs = 4000
#else
string clientId, string environment, string? redirectUri = null
Expand All @@ -61,10 +61,11 @@ public static UniTask<Passport> Init(
{
if (Instance == null)
{
Debug.Log($"{TAG} Initialising Passport...");
Instance = new Passport();
// Wait until we get a ready signal
return Instance.Initialise(
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
engineStartupTimeoutMs
#endif
)
Expand Down Expand Up @@ -94,7 +95,7 @@ public static UniTask<Passport> Init(
}

private async UniTask Initialise(
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
int engineStartupTimeoutMs
#endif
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class GreeBrowserClient : IWebBrowserClient
private const string TAG = "[GreeBrowserClient]";
private const string ANDROID_DATA_DIRECTORY = "android_asset";
private const string MAC_DATA_DIRECTORY = "/Resources/Data";
private const string MAC_EDITOR_RESOURCES_DIRECTORY = "/../src/Packages/Passport/Runtime/Resources";
private readonly WebViewObject webViewObject;
public event OnUnityPostMessageDelegate OnUnityPostMessage;
public event OnUnityPostMessageDelegate OnAuthPostMessage;
Expand All @@ -25,7 +26,9 @@ public GreeBrowserClient()
);
#if UNITY_ANDROID
string filePath = Constants.SCHEME_FILE + ANDROID_DATA_DIRECTORY + Constants.PASSPORT_DATA_DIRECTORY_NAME + Constants.PASSPORT_HTML_FILE_NAME;
#elif UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
#elif UNITY_EDITOR_OSX
string filePath = Constants.SCHEME_FILE + Path.GetDirectoryName(Application.dataPath) + MAC_EDITOR_RESOURCES_DIRECTORY + Constants.PASSPORT_HTML_FILE_NAME;
#elif UNITY_STANDALONE_OSX
string filePath = Constants.SCHEME_FILE + Path.GetFullPath(Application.dataPath) + MAC_DATA_DIRECTORY + Constants.PASSPORT_DATA_DIRECTORY_NAME + Constants.PASSPORT_HTML_FILE_NAME;
#else
string filePath = Constants.SCHEME_FILE + Path.GetFullPath(Application.dataPath) + Constants.PASSPORT_DATA_DIRECTORY_NAME + Constants.PASSPORT_HTML_FILE_NAME;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading