diff --git a/Runtime/WebViewPanel.cs b/Runtime/WebViewPanel.cs index 1665df4..ee9e3e6 100644 --- a/Runtime/WebViewPanel.cs +++ b/Runtime/WebViewPanel.cs @@ -48,8 +48,12 @@ public void LoadWebView(string loginToken = "") #else InitializeAndShowWebView(loginToken); #endif - messagePanel.SetMessage(messageType); - messagePanel.SetVisible(true); + if(messagePanel) + { + messagePanel.SetMessage(messageType); + messagePanel.SetVisible(true); + } + SetScreenPadding(); } @@ -92,8 +96,12 @@ public void ReloadWithLoginToken(string loginToken = "") /// public void SetVisible(bool visible) { - messagePanel.SetVisible(visible); - if (webViewObject != null) + if (messagePanel) + { + messagePanel.SetVisible(visible); + } + + if (webViewObject) { webViewObject.IsVisible = visible; } @@ -102,7 +110,7 @@ public void SetVisible(bool visible) private void OnDrawGizmos() { var rectTransform = transform as RectTransform; - if (rectTransform != null) + if (rectTransform) { Gizmos.matrix = rectTransform.localToWorldMatrix; Gizmos.color = Color.green; @@ -123,7 +131,10 @@ private void SetScreenPadding() webViewObject.SetMargins(screenPadding.left, screenPadding.top, screenPadding.right, screenPadding.bottom); } - messagePanel.SetMargins(screenPadding.left, screenPadding.top, screenPadding.right, screenPadding.bottom); + if (messagePanel) + { + messagePanel.SetMargins(screenPadding.left, screenPadding.top, screenPadding.right, screenPadding.bottom); + } } // Receives message from RPM website, which contains avatar URL. @@ -132,7 +143,8 @@ private void OnWebMessageReceived(string message) SDKLogger.AvatarLoaderLogger.Log(TAG, $"--- WebView Message: {message}"); try { - HandleEvents(JsonConvert.DeserializeObject(message)); + var jsonMessage = JsonConvert.DeserializeObject(message); + HandleEvents(jsonMessage); } catch (Exception e) {