Skip to content

Commit 72bf1b3

Browse files
committed
Added Login Script.
[Added] Login Script
1 parent 12af808 commit 72bf1b3

File tree

5 files changed

+67
-1
lines changed

5 files changed

+67
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[V.1.0.2]
2+
* Added Login script for easier implementation.

Runtime/Phantasma/Scripts/Utils.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using UnityEngine;
5+
6+
public class Login : MonoBehaviour
7+
{
8+
#region Events
9+
public event Action<string,bool> OnLoginEvent;
10+
#endregion
11+
12+
/// <summary>
13+
/// Method used to connect to the wallet.
14+
/// </summary>
15+
public void OnLogin()
16+
{
17+
if (PhantasmaLinkClient.Instance.Ready)
18+
{
19+
if ( !PhantasmaLinkClient.Instance.IsLogged)
20+
PhantasmaLinkClient.Instance.Login((result, msg) =>
21+
{
22+
if (result)
23+
{
24+
// Call event to Handle Login
25+
OnLoginEvent?.Invoke("Logged In.", false);
26+
Debug.LogWarning("Phantasma Link authorization logged.");
27+
}
28+
else
29+
{
30+
OnLoginEvent?.Invoke("Phantasma Link authorization failed.", true);
31+
Debug.LogWarning("Phantasma Link authorization failed.");
32+
}
33+
});
34+
else
35+
OnLoginEvent?.Invoke("Logged In.", false);
36+
}
37+
else
38+
{
39+
Debug.LogWarning("Phantasma Link connection is not ready.");
40+
OnLoginEvent?.Invoke("Phantasma Link connection is not ready.", true);
41+
PhantasmaLinkClient.Instance.Enable();
42+
}
43+
}
44+
45+
}

Runtime/Phantasma/Scripts/Utils/Login.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.phantasma.phantasmalinkclient",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"displayName": "Phantasma Link Client",
55
"description": "Phantasma Link Client, use to connect to the Phantasma Blockchain",
66
"unity": "2020.3",

0 commit comments

Comments
 (0)