-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumteHudSimpleUI.cs
More file actions
86 lines (67 loc) · 2.33 KB
/
NumteHudSimpleUI.cs
File metadata and controls
86 lines (67 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using Nethereum.Unity.Behaviours;
namespace Nethereum.Unity.Behaviours.UI
{
public class NumteHudSimpleUI : MonoBehaviour
{
[SerializeField]
EthereumAccountBehaviour _accountBehaviour;
[SerializeField]
long _targetTokenId = 0;
[SerializeField]
Text _nameText;
[SerializeField]
Text _contractText;
[SerializeField]
Text _tokenText;
[SerializeField]
Text _tokensOwnedText;
[SerializeField]
Text _latestTransactionsText;
private float _timePassedInSeconds = 0.0f;
private int _lastTimeThreshold = 0;
// Start is called before the first frame update
void Start()
{
UpdateDisplay();
}
// Update is called once per frame
void Update()
{
AdjustTimer();
}
private void AdjustTimer()
{
_timePassedInSeconds += Time.deltaTime;
int timePassed = (int)_timePassedInSeconds;
if ((timePassed > 1) && (timePassed > _lastTimeThreshold))
{
_lastTimeThreshold = timePassed;
UpdateDisplay();
}
}
private void UpdateDisplay()
{
if ((_accountBehaviour != null) && (_targetTokenId > 0))
{
System.Numerics.BigInteger targetTokenIdBI = _targetTokenId;
_nameText.text = _accountBehaviour.Name;
_contractText.text = _accountBehaviour.Contract.GetRootNode().ContractName;
_tokenText.text = _accountBehaviour.GetTokenName(targetTokenIdBI);
Debug.Log("NumteHudSimpleUI::UpdateDisplay() -> Name(" + _nameText.text +
"), Contract(" + _contractText.text + "), Token(" + _tokenText.text + ")");
var tokensOwned = _accountBehaviour.GetTokensOwned(targetTokenIdBI);
if (tokensOwned > 0)
{
_tokensOwnedText.text = Convert.ToString(tokensOwned);
}
_latestTransactionsText.text = _accountBehaviour.GetUserFriendlyLatestTransactionsReport();
}
}
}
}