Skip to content

Commit 5820501

Browse files
committed
chore: add webgl template
1 parent 61df2c8 commit 5820501

19 files changed

+602
-19
lines changed

sample/Assets/Scripts/SelectAuthMethodScript.cs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,22 @@ public class SelectAuthMethodScript : MonoBehaviour
1212
[SerializeField] private Text Output;
1313
[SerializeField] private Button UseDeviceCodeAuthButton;
1414
[SerializeField] private Button UsePKCEButton;
15-
string REDIRECT_URI = null;
16-
string LOGOUT_REIDIRECT_URI = "https://www.immutable.com";
15+
string redirectUri = null;
16+
string logoutRedirectUri = "https://www.immutable.com";
17+
string clientId = "ZJL7JvetcDFBNDlgRs5oJoxuAUUl6uQj";
1718
#pragma warning restore CS8618
1819
void Start()
1920
{
2021
#if UNITY_WEBGL
21-
string url = Application.absoluteURL;
22-
Uri uri = new Uri(url);
23-
string scheme = uri.Scheme;
24-
string hostWithPort = uri.IsDefaultPort ? uri.Host : $"{uri.Host}:{uri.Port}";
25-
string fullPath = uri.AbsolutePath.EndsWith("/") ? uri.AbsolutePath : uri.AbsolutePath.Substring(0, uri.AbsolutePath.LastIndexOf('/') + 1);
22+
string url = Application.absoluteURL;
23+
Uri uri = new Uri(url);
24+
string scheme = uri.Scheme;
25+
string hostWithPort = uri.IsDefaultPort ? uri.Host : $"{uri.Host}:{uri.Port}";
26+
string fullPath = uri.AbsolutePath.EndsWith("/") ? uri.AbsolutePath : uri.AbsolutePath.Substring(0, uri.AbsolutePath.LastIndexOf('/') + 1);
2627

27-
REDIRECT_URI = $"{scheme}://{hostWithPort}{fullPath}callback.html";
28-
LOGOUT_REIDIRECT_URI = $"{scheme}://{hostWithPort}{fullPath}logout.html";
28+
redirectUri = $"{scheme}://{hostWithPort}{fullPath}callback.html";
29+
logoutRedirectUri = $"{scheme}://{hostWithPort}{fullPath}logout.html";
30+
clientId = "UnB98ngnXIZIEJWGJOjVe1BpCx5ix7qc";
2931
#endif
3032

3133
// Determine if PKCE is supported based on the platform
@@ -34,7 +36,7 @@ void Start()
3436
// If PKCE is not supported, initialise Passport to use Device Code Auth
3537
if (!SampleAppManager.SupportsPKCE)
3638
{
37-
InitialisePassport(redirectUri: REDIRECT_URI, logoutRedirectUri: LOGOUT_REIDIRECT_URI);
39+
InitialisePassport();
3840
}
3941
}
4042

@@ -56,7 +58,7 @@ private bool IsPKCESupported()
5658
public void UseDeviceCodeAuth()
5759
{
5860
SampleAppManager.UsePKCE = false;
59-
InitialisePassport(redirectUri: REDIRECT_URI, logoutRedirectUri: LOGOUT_REIDIRECT_URI);
61+
InitialisePassport();
6062
}
6163

6264
/// <summary>
@@ -65,17 +67,13 @@ public void UseDeviceCodeAuth()
6567
public void UsePKCE()
6668
{
6769
SampleAppManager.UsePKCE = true;
68-
InitialisePassport(redirectUri: REDIRECT_URI, logoutRedirectUri: LOGOUT_REIDIRECT_URI);
70+
InitialisePassport();
6971
}
7072

7173
/// <summary>
7274
/// Initialises Passport.
7375
/// </summary>
74-
/// <param name="redirectUri">(Android, iOS and macOS only) The URL to which auth will redirect the browser after
75-
/// authorisation has been granted by the user</param>
76-
/// <param name="logoutRedirectUri">The URL to which auth will redirect the browser
77-
/// after log out is complete</param>
78-
private async void InitialisePassport(string redirectUri = null, string logoutRedirectUri = null)
76+
private async void InitialisePassport()
7977
{
8078
ShowOutput("Initialising Passport...");
8179

@@ -85,7 +83,6 @@ private async void InitialisePassport(string redirectUri = null, string logoutRe
8583
Passport.LogLevel = LogLevel.Info;
8684

8785
// Initialise Passport
88-
string clientId = "ZJL7JvetcDFBNDlgRs5oJoxuAUUl6uQj";
8986
string environment = Immutable.Passport.Model.Environment.SANDBOX;
9087

9188
Passport passport = await Passport.Init(clientId, environment, redirectUri, logoutRedirectUri);

sample/Assets/WebGLTemplates/unity-webview/Passport/index.html

Lines changed: 351 additions & 0 deletions
Large diffs are not rendered by default.
665 Bytes
Loading
Binary file not shown.
175 Bytes
Loading
96 Bytes
Loading
109 Bytes
Loading
74 Bytes
Loading
84 Bytes
Loading
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
body { padding: 0; margin: 0 }
2+
#unity-container { position: absolute }
3+
#unity-container.unity-desktop { left: 50%; top: 50%; transform: translate(-50%, -50%) }
4+
#unity-container.unity-mobile { position: fixed; width: 100%; height: 100% }
5+
#unity-canvas { background: {{{ BACKGROUND_COLOR }}} }
6+
.unity-mobile #unity-canvas { width: 100%; height: 100% }
7+
#unity-loading-bar { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none }
8+
#unity-logo { width: 154px; height: 130px; background: url('unity-logo-{{{ SPLASH_SCREEN_STYLE.toLowerCase() }}}.png') no-repeat center }
9+
#unity-progress-bar-empty { width: 141px; height: 18px; margin-top: 10px; margin-left: 6.5px; background: url('progress-bar-empty-{{{ SPLASH_SCREEN_STYLE.toLowerCase() }}}.png') no-repeat center }
10+
#unity-progress-bar-full { width: 0%; height: 18px; margin-top: 10px; background: url('progress-bar-full-{{{ SPLASH_SCREEN_STYLE.toLowerCase() }}}.png') no-repeat center }
11+
#unity-footer { position: relative }
12+
.unity-mobile #unity-footer { display: none }
13+
#unity-webgl-logo { float:left; width: 204px; height: 38px; background: url('webgl-logo.png') no-repeat center }
14+
#unity-build-title { float: right; margin-right: 10px; line-height: 38px; font-family: arial; font-size: 18px }
15+
#unity-fullscreen-button { cursor:pointer; float: right; width: 38px; height: 38px; background: url('fullscreen-button.png') no-repeat center }
16+
#unity-warning { position: absolute; left: 50%; top: 5%; transform: translate(-50%); background: white; padding: 10px; display: none }

0 commit comments

Comments
 (0)