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

Asset Store Validator Warnings Fixed #109

Merged
merged 3 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [Bug](https://github.com/trilitech/tezos-unity-sdk/issues/102) with standalone IL2CPP build fails
- [Bug](https://github.com/trilitech/tezos-unity-sdk/issues/103) with closing Beacon database connections before app exit

### Added
- Missing namespaces

### Changed
- Issue Report Form menu item path changed (new path: `Tools/Tezos SDK for Unity/Report an Issue`)


## [1.5.1] - 2023-06-27
### Fixed
Expand Down
4 changes: 2 additions & 2 deletions Editor/IssueReportFormWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Newtonsoft.Json.Linq;
using UnityEngine.Networking;

namespace Tezos.Editor.Windows
namespace TezosSDK.Editor.Windows
{
public class IssueReportFormWindow : EditorWindow
{
Expand All @@ -19,7 +19,7 @@ public class IssueReportFormWindow : EditorWindow
private string errorMessage = "";
private string successMessage = "";

[MenuItem("Tezos SDK/Issue Report Form")]
[MenuItem("Tools/Tezos SDK for Unity/Report an Issue")]
public static void ShowWindow()
{
GetWindow<IssueReportFormWindow>("Issue Report Form");
Expand Down
111 changes: 57 additions & 54 deletions Runtime/View/AuthenticationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,83 +2,86 @@
using TezosSDK.Tezos.Wallet;
using UnityEngine;

public class AuthenticationManager : MonoBehaviour
namespace TezosSDK.View
{
private ITezos _tezos;
[SerializeField] private QRCodeView qrCodeView;
[SerializeField] private GameObject contentPanel;
[SerializeField] private GameObject deepLinkButton;
[SerializeField] private GameObject logoutButton;
[SerializeField] private GameObject qrCodePanel;
public class AuthenticationManager : MonoBehaviour
{
private ITezos _tezos;
[SerializeField] private QRCodeView qrCodeView;
[SerializeField] private GameObject contentPanel;
[SerializeField] private GameObject deepLinkButton;
[SerializeField] private GameObject logoutButton;
[SerializeField] private GameObject qrCodePanel;

private bool _isMobile;
private bool _isMobile;

void Start()
{
void Start()
{
#if (UNITY_IOS || UNITY_ANDROID)
_isMobile = true;
#else
_isMobile = false;
_isMobile = false;
#endif
_tezos = TezosSingleton.Instance;

_tezos.Wallet.MessageReceiver.HandshakeReceived += OnHandshakeReceived;
_tezos.Wallet.MessageReceiver.AccountConnected += OnAccountConnected;
_tezos.Wallet.MessageReceiver.AccountDisconnected += OnAccountDisconnected;
}
_tezos = TezosSingleton.Instance;

void OnHandshakeReceived(string handshake)
{
EnableUI(isAuthenticated: false);
qrCodeView.SetQrCode(handshake);
}
_tezos.Wallet.MessageReceiver.HandshakeReceived += OnHandshakeReceived;
_tezos.Wallet.MessageReceiver.AccountConnected += OnAccountConnected;
_tezos.Wallet.MessageReceiver.AccountDisconnected += OnAccountDisconnected;
}

void OnAccountConnected(string result)
{
EnableUI(isAuthenticated: true);
Debug.Log("OnAccountConnected");
}
void OnHandshakeReceived(string handshake)
{
EnableUI(isAuthenticated: false);
qrCodeView.SetQrCode(handshake);
}

void OnAccountDisconnected(string result)
{
Debug.Log("OnAccountDisconnected");
}
void OnAccountConnected(string result)
{
EnableUI(isAuthenticated: true);
Debug.Log("OnAccountConnected");
}

public void DisconnectWallet()
{
EnableUI(isAuthenticated: false);
_tezos.Wallet.Disconnect();
}
void OnAccountDisconnected(string result)
{
Debug.Log("OnAccountDisconnected");
}

public void ConnectByDeeplink()
{
_tezos.Wallet.Connect(WalletProviderType.beacon);
}
public void DisconnectWallet()
{
EnableUI(isAuthenticated: false);
_tezos.Wallet.Disconnect();
}

void EnableUI(bool isAuthenticated)
{
if (isAuthenticated)
public void ConnectByDeeplink()
{
deepLinkButton.SetActive(false);
qrCodePanel.SetActive(false);
_tezos.Wallet.Connect(WalletProviderType.beacon);
}
else

void EnableUI(bool isAuthenticated)
{
if (_isMobile)
if (isAuthenticated)
{
deepLinkButton.SetActive(true);
deepLinkButton.SetActive(false);
qrCodePanel.SetActive(false);
}
else
{
qrCodePanel.SetActive(true);
deepLinkButton.SetActive(false);
if (_isMobile)
{
deepLinkButton.SetActive(true);
qrCodePanel.SetActive(false);
}
else
{
qrCodePanel.SetActive(true);
deepLinkButton.SetActive(false);
}
}
}

logoutButton.SetActive(isAuthenticated);
logoutButton.SetActive(isAuthenticated);

if (contentPanel == null) return;
contentPanel.SetActive(isAuthenticated);
if (contentPanel == null) return;
contentPanel.SetActive(isAuthenticated);
}
}
}
70 changes: 36 additions & 34 deletions Runtime/View/QRCodeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,53 @@
using ZXing;
using ZXing.QrCode;


public class QRCodeView : MonoBehaviour
namespace TezosSDK.View
{
[SerializeField] private RawImage _rawImage;
private Texture2D _texture;

void Start()
{
if (_texture != null) return;

_rawImage.texture = _texture = new Texture2D(256, 256);
_texture.filterMode = FilterMode.Point;
}

public void SetQrCode(string handshake)
public class QRCodeView : MonoBehaviour
{
var uri = "tezos://?type=tzip10&data=" + handshake;
EncodeTextToQrCode(uri);
}
[SerializeField] private RawImage _rawImage;
private Texture2D _texture;

public void EncodeTextToQrCode(string text)
{
if (_texture == null)
void Start()
{
if (_texture != null) return;

_rawImage.texture = _texture = new Texture2D(256, 256);
_texture.filterMode = FilterMode.Point;
}

var colors = Encode(text, _texture.width, _texture.height);
_texture.SetPixels32(colors);
_texture.Apply();
}
public void SetQrCode(string handshake)
{
var uri = "tezos://?type=tzip10&data=" + handshake;
EncodeTextToQrCode(uri);
}

private Color32[] Encode(string text, int width, int height)
{
var writer = new BarcodeWriter
public void EncodeTextToQrCode(string text)
{
Format = BarcodeFormat.QR_CODE,
Options = new QrCodeEncodingOptions()
if (_texture == null)
{
Width = width,
Height = height,
PureBarcode = true
_rawImage.texture = _texture = new Texture2D(256, 256);
_texture.filterMode = FilterMode.Point;
}
};
return writer.Write(text);

var colors = Encode(text, _texture.width, _texture.height);
_texture.SetPixels32(colors);
_texture.Apply();
}

private Color32[] Encode(string text, int width, int height)
{
var writer = new BarcodeWriter
{
Format = BarcodeFormat.QR_CODE,
Options = new QrCodeEncodingOptions()
{
Width = width,
Height = height,
PureBarcode = true
}
};
return writer.Write(text);
}
}
}
58 changes: 30 additions & 28 deletions Samples~/Scripts/DemoExample/CopyToClipboard.cs
Original file line number Diff line number Diff line change
@@ -1,44 +1,46 @@
using System.Collections;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.EventSystems;
using CoroutineRunner = TezosSDK.Helpers.CoroutineRunner;

public class CopyToClipboard : MonoBehaviour, IPointerClickHandler
namespace TezosSDK.Samples.DemoExample
{
[SerializeField] TMPro.TextMeshProUGUI text;
[SerializeField] TMPro.TMP_InputField inputField;
public class CopyToClipboard : MonoBehaviour, IPointerClickHandler
{
[SerializeField] TMPro.TextMeshProUGUI text;
[SerializeField] TMPro.TMP_InputField inputField;

bool _blockCopy = false;
bool _blockCopy = false;

private void Start()
{
inputField.gameObject.SetActive(false);
}
private void Start()
{
inputField.gameObject.SetActive(false);
}

public void OnPointerClick(PointerEventData eventData)
{
if (_blockCopy)
return;

public void OnPointerClick(PointerEventData eventData)
{
if (_blockCopy)
return;

#if UNITY_WEBGL
inputField.gameObject.SetActive(true);
inputField.text = text.text;
text.gameObject.SetActive(false);
#endif

// copy text to the clipboard
GUIUtility.systemCopyBuffer = text.text;
CoroutineRunner.Instance.StartWrappedCoroutine(OnTextCopied());
}

IEnumerator OnTextCopied()
{
_blockCopy = true;
string origin = text.text;
text.text = "Copied to clipboard.";
yield return new WaitForSeconds(1.5f);
text.text = origin;
_blockCopy = false;
// copy text to the clipboard
GUIUtility.systemCopyBuffer = text.text;
CoroutineRunner.Instance.StartWrappedCoroutine(OnTextCopied());
}

IEnumerator OnTextCopied()
{
_blockCopy = true;
string origin = text.text;
text.text = "Copied to clipboard.";
yield return new WaitForSeconds(1.5f);
text.text = origin;
_blockCopy = false;
}
}
}
}
Loading