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

safer null check for MessagePanel #41

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
23 changes: 17 additions & 6 deletions Runtime/WebViewPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -92,8 +96,12 @@ public void ReloadWithLoginToken(string loginToken = "")
/// </summary>
public void SetVisible(bool visible)
{
messagePanel.SetVisible(visible);
if (webViewObject != null)
if (messagePanel)
{
messagePanel.SetVisible(visible);
}

if (webViewObject)
{
webViewObject.IsVisible = visible;
}
Expand All @@ -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;
Expand All @@ -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.
Expand Down