Skip to content

Commit

Permalink
Added Login Script.
Browse files Browse the repository at this point in the history
[Added] Login Script
  • Loading branch information
TeknoPT committed Apr 26, 2022
1 parent 12af808 commit 72bf1b3
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[V.1.0.2]
* Added Login script for easier implementation.
8 changes: 8 additions & 0 deletions Runtime/Phantasma/Scripts/Utils.meta

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

45 changes: 45 additions & 0 deletions Runtime/Phantasma/Scripts/Utils/Login.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Login : MonoBehaviour
{
#region Events
public event Action<string,bool> OnLoginEvent;
#endregion

/// <summary>
/// Method used to connect to the wallet.
/// </summary>
public void OnLogin()
{
if (PhantasmaLinkClient.Instance.Ready)
{
if ( !PhantasmaLinkClient.Instance.IsLogged)
PhantasmaLinkClient.Instance.Login((result, msg) =>
{
if (result)
{
// Call event to Handle Login
OnLoginEvent?.Invoke("Logged In.", false);
Debug.LogWarning("Phantasma Link authorization logged.");
}
else
{
OnLoginEvent?.Invoke("Phantasma Link authorization failed.", true);
Debug.LogWarning("Phantasma Link authorization failed.");
}
});
else
OnLoginEvent?.Invoke("Logged In.", false);
}
else
{
Debug.LogWarning("Phantasma Link connection is not ready.");
OnLoginEvent?.Invoke("Phantasma Link connection is not ready.", true);
PhantasmaLinkClient.Instance.Enable();
}
}

}
11 changes: 11 additions & 0 deletions Runtime/Phantasma/Scripts/Utils/Login.cs.meta

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.phantasma.phantasmalinkclient",
"version": "1.0.1",
"version": "1.0.2",
"displayName": "Phantasma Link Client",
"description": "Phantasma Link Client, use to connect to the Phantasma Blockchain",
"unity": "2020.3",
Expand Down

0 comments on commit 72bf1b3

Please sign in to comment.