From 87a9d15de7dddb4b6519072bd1b7753eef79a684 Mon Sep 17 00:00:00 2001 From: Andrew Yang Date: Tue, 8 Oct 2024 14:07:00 +1100 Subject: [PATCH] chore: add webgl template --- .../Assets/Scripts/SelectAuthMethodScript.cs | 33 +- .../unity-webview/Passport/index.html | 351 ++++++++++++++++++ .../TemplateData/MemoryProfiler.png | Bin 0 -> 665 bytes .../unity-webview/TemplateData/favicon.ico | Bin 0 -> 2305 bytes .../TemplateData/fullscreen-button.png | Bin 0 -> 175 bytes .../TemplateData/progress-bar-empty-dark.png | Bin 0 -> 96 bytes .../TemplateData/progress-bar-empty-light.png | Bin 0 -> 109 bytes .../TemplateData/progress-bar-full-dark.png | Bin 0 -> 74 bytes .../TemplateData/progress-bar-full-light.png | Bin 0 -> 84 bytes .../unity-webview/TemplateData/style.css | 16 + .../TemplateData/unity-logo-dark.png | Bin 0 -> 3042 bytes .../TemplateData/unity-logo-light.png | Bin 0 -> 3077 bytes .../unity-webview/TemplateData/webgl-logo.png | Bin 0 -> 2947 bytes .../TemplateData/webmemd-icon.png | Bin 0 -> 1670 bytes .../unity-webview/callback.html | 24 ++ .../WebGLTemplates/unity-webview/index.html | 99 +++++ .../WebGLTemplates/unity-webview/logout.html | 24 ++ .../unity-webview/unity-webview.js | 72 ++++ sample/ProjectSettings/ProjectSettings.asset | 2 +- 19 files changed, 602 insertions(+), 19 deletions(-) create mode 100644 sample/Assets/WebGLTemplates/unity-webview/Passport/index.html create mode 100644 sample/Assets/WebGLTemplates/unity-webview/TemplateData/MemoryProfiler.png create mode 100644 sample/Assets/WebGLTemplates/unity-webview/TemplateData/favicon.ico create mode 100644 sample/Assets/WebGLTemplates/unity-webview/TemplateData/fullscreen-button.png create mode 100644 sample/Assets/WebGLTemplates/unity-webview/TemplateData/progress-bar-empty-dark.png create mode 100644 sample/Assets/WebGLTemplates/unity-webview/TemplateData/progress-bar-empty-light.png create mode 100644 sample/Assets/WebGLTemplates/unity-webview/TemplateData/progress-bar-full-dark.png create mode 100644 sample/Assets/WebGLTemplates/unity-webview/TemplateData/progress-bar-full-light.png create mode 100644 sample/Assets/WebGLTemplates/unity-webview/TemplateData/style.css create mode 100644 sample/Assets/WebGLTemplates/unity-webview/TemplateData/unity-logo-dark.png create mode 100644 sample/Assets/WebGLTemplates/unity-webview/TemplateData/unity-logo-light.png create mode 100644 sample/Assets/WebGLTemplates/unity-webview/TemplateData/webgl-logo.png create mode 100644 sample/Assets/WebGLTemplates/unity-webview/TemplateData/webmemd-icon.png create mode 100644 sample/Assets/WebGLTemplates/unity-webview/callback.html create mode 100644 sample/Assets/WebGLTemplates/unity-webview/index.html create mode 100644 sample/Assets/WebGLTemplates/unity-webview/logout.html create mode 100644 sample/Assets/WebGLTemplates/unity-webview/unity-webview.js diff --git a/sample/Assets/Scripts/SelectAuthMethodScript.cs b/sample/Assets/Scripts/SelectAuthMethodScript.cs index 528207ec..32bc5c84 100644 --- a/sample/Assets/Scripts/SelectAuthMethodScript.cs +++ b/sample/Assets/Scripts/SelectAuthMethodScript.cs @@ -12,20 +12,22 @@ public class SelectAuthMethodScript : MonoBehaviour [SerializeField] private Text Output; [SerializeField] private Button UseDeviceCodeAuthButton; [SerializeField] private Button UsePKCEButton; - string REDIRECT_URI = null; - string LOGOUT_REIDIRECT_URI = "https://www.immutable.com"; + string redirectUri = null; + string logoutRedirectUri = "https://www.immutable.com"; + string clientId = "ZJL7JvetcDFBNDlgRs5oJoxuAUUl6uQj"; #pragma warning restore CS8618 void Start() { #if UNITY_WEBGL - string url = Application.absoluteURL; - Uri uri = new Uri(url); - string scheme = uri.Scheme; - string hostWithPort = uri.IsDefaultPort ? uri.Host : $"{uri.Host}:{uri.Port}"; - string fullPath = uri.AbsolutePath.EndsWith("/") ? uri.AbsolutePath : uri.AbsolutePath.Substring(0, uri.AbsolutePath.LastIndexOf('/') + 1); + string url = Application.absoluteURL; + Uri uri = new Uri(url); + string scheme = uri.Scheme; + string hostWithPort = uri.IsDefaultPort ? uri.Host : $"{uri.Host}:{uri.Port}"; + string fullPath = uri.AbsolutePath.EndsWith("/") ? uri.AbsolutePath : uri.AbsolutePath.Substring(0, uri.AbsolutePath.LastIndexOf('/') + 1); - REDIRECT_URI = $"{scheme}://{hostWithPort}{fullPath}callback.html"; - LOGOUT_REIDIRECT_URI = $"{scheme}://{hostWithPort}{fullPath}logout.html"; + redirectUri = $"{scheme}://{hostWithPort}{fullPath}callback.html"; + logoutRedirectUri = $"{scheme}://{hostWithPort}{fullPath}logout.html"; + clientId = "UnB98ngnXIZIEJWGJOjVe1BpCx5ix7qc"; #endif // Determine if PKCE is supported based on the platform @@ -34,7 +36,7 @@ void Start() // If PKCE is not supported, initialise Passport to use Device Code Auth if (!SampleAppManager.SupportsPKCE) { - InitialisePassport(redirectUri: REDIRECT_URI, logoutRedirectUri: LOGOUT_REIDIRECT_URI); + InitialisePassport(); } } @@ -56,7 +58,7 @@ private bool IsPKCESupported() public void UseDeviceCodeAuth() { SampleAppManager.UsePKCE = false; - InitialisePassport(redirectUri: REDIRECT_URI, logoutRedirectUri: LOGOUT_REIDIRECT_URI); + InitialisePassport(); } /// @@ -65,17 +67,13 @@ public void UseDeviceCodeAuth() public void UsePKCE() { SampleAppManager.UsePKCE = true; - InitialisePassport(redirectUri: REDIRECT_URI, logoutRedirectUri: LOGOUT_REIDIRECT_URI); + InitialisePassport(); } /// /// Initialises Passport. /// - /// (Android, iOS and macOS only) The URL to which auth will redirect the browser after - /// authorisation has been granted by the user - /// The URL to which auth will redirect the browser - /// after log out is complete - private async void InitialisePassport(string redirectUri = null, string logoutRedirectUri = null) + private async void InitialisePassport() { ShowOutput("Initialising Passport..."); @@ -85,7 +83,6 @@ private async void InitialisePassport(string redirectUri = null, string logoutRe Passport.LogLevel = LogLevel.Info; // Initialise Passport - string clientId = "ZJL7JvetcDFBNDlgRs5oJoxuAUUl6uQj"; string environment = Immutable.Passport.Model.Environment.SANDBOX; Passport passport = await Passport.Init(clientId, environment, redirectUri, logoutRedirectUri); diff --git a/sample/Assets/WebGLTemplates/unity-webview/Passport/index.html b/sample/Assets/WebGLTemplates/unity-webview/Passport/index.html new file mode 100644 index 00000000..5fade945 --- /dev/null +++ b/sample/Assets/WebGLTemplates/unity-webview/Passport/index.html @@ -0,0 +1,351 @@ +GameSDK Bridge

Bridge Running

\ No newline at end of file diff --git a/sample/Assets/WebGLTemplates/unity-webview/TemplateData/MemoryProfiler.png b/sample/Assets/WebGLTemplates/unity-webview/TemplateData/MemoryProfiler.png new file mode 100644 index 0000000000000000000000000000000000000000..2e264c7be1ed0f2bcc336aaf38c409ec61ccf4a9 GIT binary patch literal 665 zcmV;K0%rY*P)-5U3zXe8df?Afy6F1%V2H8v+hX1&|I%1-OHdGrznStyc!IAG1ri z@T3)Ed+Zs{yqR5uxFICUc#Zi-Y9+*+tFMG05@s@)4>)0o=#curjQ~iN*B6dS z2-M+39rMBi4V=*j)4vdf94^E>PjvHn9NTpH_e1+@A z38d&p-w?XFC{E}N$zyJbQp}@bq?%*+S$@uN1^qj%_jD&Z_0x}*aq zfpm10jA*o!Y|;s3ggJgub<*kdGsI8I;syu5(EIZue8qXI1=7yYJ~0L<@V<`TTQ0hTIjEuQO(2^^ zl5LOMnpxCWKe%*avh$^l{oq7n#Mamg-*RH7YXUQKPw1(o{qa|%?f-}@PPDT)KE6Bi z*Mk+O3HV3M6pggKPBUR<^PqJ;t@p=#Zsv6j4S-1upLlWk(0G}K2l!1?p{@50gJs>> z*7mTfJM3@@0`YxFV_C@vn(s!aow{JJ2|sG}o#^{C+BY|M9{jr^Ne*HSH2sc^A5uID zjO!DBe-(j;4|87!vyXI$YtY%DB!6G-Zr0yoo=@ZQZctFzddh2woBxc(0tfhV$F-INwIy(41Y8vR5@y405 zS3A3=S2?lU04td7MI3*>=k2EF4edW*P%C#Imx&3HkDKVgDrRWdfF${zLmQ3t2V}zr z<}dlHic|7JN$9Sg1mS3ucr@Ekl7itK$rp@jQqg8b=2pOs6d7exz*Kut+B5{BskIRp zd6b_{?6%FUC)&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(ijjiF$0f9D2+UrT7%)Tsab+fk zWyZWAXx1v#ye{Bo%h&2Nlt{{!r#s&vBNNQa;vCGMctl9N@vAII`w{_8=a$Nc3Kl59 zfpOJ{7*t=Gq`7*kI`!cG1MbP0l+XkK D*ti=j literal 0 HcmV?d00001 diff --git a/sample/Assets/WebGLTemplates/unity-webview/TemplateData/progress-bar-full-dark.png b/sample/Assets/WebGLTemplates/unity-webview/TemplateData/progress-bar-full-dark.png new file mode 100644 index 0000000000000000000000000000000000000000..c432c8666d955307ec7c690ef3624e50093513fe GIT binary patch literal 74 zcmeAS@N?(olHy`uVBq!ia0vp^y+AC)2qYN%L=)x#DM3#c$B+ufeue{W|B=pC>bk0)apv5C{YU0ml$RTsh<4 z&-|W1;6xxE9*aD>XMA4`-@~KLBcecHTv#yoce-$BIINkjpE5I@=#X(>9QC8!KM-7BcwE1EC$vNz=3+`}^5}|ShuDi4->yhY znKjyJcvZhSAJK%gD=1Er5&46v-`c{1bn2|o#F1UmBRA@>tTcHby4@EJw<9?zG``?X ziUrmpJMSiorbh8=U2!#?Iwdr5WLLDwuQWL>DxI#lmQI}znoN_64MitpdQ3xjlp zC22!gV26DD`c=Go_3Dr`q0O+}+uNge@7~d;PoGFL10J)rS`A}B7Qnv;24*|%^7xhF z-%$$(2M6@#%^Q0D{5kFH?2sM~h~6kLa5cOSp& zE|tjV&!2|^gU}#2ofw&d!i)Uy;luC~RniOYP%N+(k5b>fB7op1ZUe$(`G2WkzJ2>f zFJ8PD4t#BbDKZGx3B%}i;lc&Fc<~}lPEJw*boh`2&5utVOzf1h`Dp(WF4sr8$z!)7VxI#krF5SR^~SQeaJsa}vB z5>Z^g6>f(l>7O(fPEz=IEx?Pc$8fjv4b5oE((1KJzcgTR^elZkJsKFx2h$Y<> z;`Z&^T7r#hLfhp?GN{#RnWvHR&@3vrIv*f zHbxF%@3OES@Z(aW(HOR-udc4*TI5~Dq%ERZ(P5hv7G8_R*5NmyH8C-f+WS&=2&|BT zx_f^Bkqc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y4-rn9{awZ}= z?VGs-pff=2^-nyH+`iQGT^}|CTrjz3u2G>WkixQ_=VXF0gk}Xc9rI&_&=h&j1JH>B zLbLAt0;`0kz%&x4vU_By;4BuJwdWUDDKubnI<-+~@|d6BY&~w#TA?YV1ySbgL24`$ zniJ<2ST8h%P4$~4LUZc4MQ1j7!Fd2!Sj=Bqw>Z`S&YfT2Ohij!x_&bi(Of=m(Mh2x zOr=u;LUaDOMW=t6hkGhhQOy?{-C6LPQ&ZBO4x0t=~?HXjQT+(h`Jr0#a~IIwqYS zBecrd6=?}VI|C`W77s+X2!BWjt+IAST7uBVU^JaVXq+P3vb!P(EKn>E9PAKm)Ixzk kAP@)y0)apv5ICFv0X^P^&&+3ly8r+H07*qoM6N<$f*y66+yDRo literal 0 HcmV?d00001 diff --git a/sample/Assets/WebGLTemplates/unity-webview/TemplateData/unity-logo-light.png b/sample/Assets/WebGLTemplates/unity-webview/TemplateData/unity-logo-light.png new file mode 100644 index 0000000000000000000000000000000000000000..9f0ab84b9d5f75c2c2de21c18d382c8d7adff393 GIT binary patch literal 3077 zcmZ`*dpHyP7oT#Ud$v~*HX{sa#2Q`9hUtBmBG%?Di(GP96UrrpY0Pz~H@5Z5N+dLz z>l<1wQ50crDTY+YErmwE)${xJ_dMV8J{lD#RWcS52RF1Vb!2mk>mHNS znn}rOp5e^=tFDl!FaK-#re|bqo=a<{L~AFMWYOI8Z&z1Wr@`THxwYqaSz}*b{DGZuU%XdVW?m1>4nDHQ4INQc&_-U}5*q_cDjOP5;EAy5t*xyyYfZ&2L)Z9$q3naP zH6F&A7U4%dxtEm|uLQqs_}j1W_LHdj5qkx5OkjUiCzRxujJ;pFf7i$P`75o74^ufY zQzNM3^vZ$4)#!U}e)CW9dZK;CGgF>{Je+)bdBwBC_oIbt+jWyjweMHFo2Or)$hl@b zlO`gxQF@hRk`+~;T_`YGH`55n1tEZQe0vlMRmtaD=l>y?euhe_dsd5sABo5*M#B2c z3li&~p-t_Okm9Sa!)I^eB!L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dSfWZ;B zlVN!D__OfBNAsdC{ux=GH0fE@CQw=#3~FAO)mHa z6dQ3IxbN-!+)ODp9D4bwszgDmR9B03T4Cp6)aO)jY@Bf+93yJGJZhJfIOBr=pc3+USbUi6#ccM8VXd9-lEkwZcYT^#UX>aDE zRLyw_#nQSsm$7?FUcLrecgpCdssi_l8COb$B2o`5V9m8VI6=6Qmz2>bN?xBEQFTP# zn1cs6`~}JpiE)1gwQx-RNbgq*-$3)rv#%7NQC!NNFj831q&3IgdUbUiq#2*NLEj5dZ33$1naD DiO(b9 literal 0 HcmV?d00001 diff --git a/sample/Assets/WebGLTemplates/unity-webview/callback.html b/sample/Assets/WebGLTemplates/unity-webview/callback.html new file mode 100644 index 00000000..4ace93f9 --- /dev/null +++ b/sample/Assets/WebGLTemplates/unity-webview/callback.html @@ -0,0 +1,24 @@ + + + + + + Unity WebGL Player | Immutable Runner + + + + + + +
+
Logging in
+
+ + + diff --git a/sample/Assets/WebGLTemplates/unity-webview/index.html b/sample/Assets/WebGLTemplates/unity-webview/index.html new file mode 100644 index 00000000..c8a91315 --- /dev/null +++ b/sample/Assets/WebGLTemplates/unity-webview/index.html @@ -0,0 +1,99 @@ + + + + + + Unity WebGL Player | Immutable Runner + + + + + + +
+ +
+ +
+
+
+
+ +
+ + + diff --git a/sample/Assets/WebGLTemplates/unity-webview/logout.html b/sample/Assets/WebGLTemplates/unity-webview/logout.html new file mode 100644 index 00000000..f0588154 --- /dev/null +++ b/sample/Assets/WebGLTemplates/unity-webview/logout.html @@ -0,0 +1,24 @@ + + + + + + Unity WebGL Player | Immutable Runner + + + + + + +
+
Logging out
+
+ + + diff --git a/sample/Assets/WebGLTemplates/unity-webview/unity-webview.js b/sample/Assets/WebGLTemplates/unity-webview/unity-webview.js new file mode 100644 index 00000000..8d8f0f2e --- /dev/null +++ b/sample/Assets/WebGLTemplates/unity-webview/unity-webview.js @@ -0,0 +1,72 @@ +var unityWebView = + { + loaded: [], + + init: function(name) { + $containers = $('.webviewContainer'); + if ($containers.length === 0) { + $('
') + .appendTo($('#unity-container')); + } + var $last = $('.webviewContainer:last'); + var clonedTop = parseInt($last.css('top')) - 100; + var $clone = $last.clone().insertAfter($last).css('top', clonedTop + '%'); + var $iframe = + $('') + .attr('id', 'webview_' + name) + .appendTo($last) + $iframe.on('load', function () { + $(this).attr('loaded', 'true'); + + var js = `window.Unity = { + call:function(msg) { + parent.unityWebView.sendMessage('${name}', msg); + } + };`; + + this.contentWindow.eval(js); + + window.addEventListener('message', function(event) { + if ((event.data.type === 'callback' || event.data.type === 'logout') && event.isTrusted) { + unityInstance.SendMessage(name, 'CallOnAuth', event.data.url); + } + }, false); + }); + return $iframe; + }, + + sendMessage: function (name, message) { + unityInstance.SendMessage(name, "CallFromJS", message); + }, + + loadURL: function(name, url) { + var baseUrl = window.location.origin + window.location.pathname.replace(/\/[^\/]*$/, ""); + console.log(url, window.location.origin, window.location.pathname); + console.log(baseUrl); + const host = window.location.origin.includes('localhost') ? window.location.origin : baseUrl; + this.iframe(name).attr('loaded', 'false')[0].contentWindow.location.replace(host + url); + }, + + evaluateJS: function (name, js) { + $iframe = this.iframe(name); + if ($iframe.attr('loaded') === 'true') { + $iframe[0].contentWindow.eval(js); + } else { + $iframe.on('load', function(){ + $(this)[0].contentWindow.eval(js); + }); + } + }, + + destroy: function (name) { + this.iframe(name).parent().parent().remove(); + }, + + iframe: function (name) { + return $('#webview_' + name); + }, + + launchAuthURL: function(name, url) { + window.open(url, '_blank', 'width=460,height=660'); + }, + }; diff --git a/sample/ProjectSettings/ProjectSettings.asset b/sample/ProjectSettings/ProjectSettings.asset index bba9c11a..b0552849 100644 --- a/sample/ProjectSettings/ProjectSettings.asset +++ b/sample/ProjectSettings/ProjectSettings.asset @@ -762,7 +762,7 @@ PlayerSettings: webGLTemplate: PROJECT:unity-webview webGLAnalyzeBuildSize: 0 webGLUseEmbeddedResources: 0 - webGLCompressionFormat: 2 + webGLCompressionFormat: 0 webGLWasmArithmeticExceptions: 0 webGLLinkerTarget: 1 webGLThreadsSupport: 0