Skip to content

Commit fecceaa

Browse files
committed
1.1.0
1 parent 17add11 commit fecceaa

File tree

10 files changed

+78
-65
lines changed

10 files changed

+78
-65
lines changed

Runtime/UI/Context/ContextSelector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void FillContext (Dictionary<string, ContextualEmote> _ContextEmotes)
7878
{
7979
listCardsSlotContext.Add (GetContextCard (index, contextEmote.Value));
8080

81-
AnimationIds _ids = new AnimationIds(contextEmote.Value.EmoteUuid);
81+
AnimationIds _ids = new AnimationIds(contextEmote.Value.EmoteID);
8282
KinetixCore.Metadata.IsAnimationOwnedByUser(_ids, owned =>
8383
{
8484
ContextCard ctxCard = listCardsSlotContext[index];

Runtime/UI/Create/CreateView.cs

Lines changed: 62 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4,110 +4,123 @@
44
// // </copyright>
55
// // ----------------------------------------------------------------------------
66

7-
using System;
87
using Kinetix.UI.Common;
98
using UnityEngine;
109
using UnityEngine.UI;
11-
using System.Collections;
1210
using Kinetix.Internal;
13-
using TMPro;
14-
1511

1612
namespace Kinetix.UI.EmoteWheel
1713
{
1814
public class CreateView : CategoryView
1915
{
20-
[Header("QR CODE SETTINGS")]
16+
[Header("QR CODE SETTINGS")] [SerializeField]
17+
private Image qrCodeImage;
2118

22-
[SerializeField] private Image qrCodeImage;
2319
[SerializeField] private Button btnCopy;
2420
[SerializeField] private Button btnURL;
2521

2622
[SerializeField] private Color highlightColor = Color.black;
27-
[SerializeField] private Color dominantColor = Color.white;
23+
[SerializeField] private Color dominantColor = Color.white;
2824

29-
private string ugcURL = string.Empty;
25+
private string ugcURL = string.Empty;
3026
private Texture2D texture;
3127

32-
private Coroutine timeOutCoroutine;
33-
28+
private bool isFetching;
3429

3530
public void Init()
3631
{
3732
#if UNITY_WEBGL
3833
btnCopy.gameObject.SetActive(false);
39-
btnURL.gameObject.GetComponent<RectTransform>().offsetMax = new Vector2(-20, btnURL.gameObject.GetComponent<RectTransform>().offsetMax.y);
34+
btnURL.gameObject.GetComponent<RectTransform>().offsetMax =
35+
new Vector2(-20, btnURL.gameObject.GetComponent<RectTransform>().offsetMax.y);
4036
#else
4137
btnCopy.onClick.AddListener(OnCopyLinkToClipboard);
42-
#endif
38+
#endif
4339
btnURL.onClick.AddListener(OnClickURL);
4440

45-
KinetixCore.UGC.OnUGCTokenExpired += () => {
46-
KinetixCore.UGC.GetUgcUrl(OnUgcUrlFetched);
47-
};
41+
InitCreateSystem();
42+
}
43+
44+
private void InitCreateSystem()
45+
{
46+
KinetixCore.UGC.OnUGCTokenExpired += OnTokenExpired;
47+
KinetixCore.Account.OnDisconnectedAccount += DisposeFetchUgcUrl;
4848
}
4949

5050
protected override void OnDestroy()
5151
{
52-
btnCopy.onClick.AddListener(OnCopyLinkToClipboard);
53-
btnURL.onClick.AddListener(OnClickURL);
52+
if (btnCopy != null)
53+
btnCopy.onClick.AddListener(OnCopyLinkToClipboard);
54+
if (btnURL != null)
55+
btnURL.onClick.AddListener(OnClickURL);
5456

55-
KinetixCore.UGC.OnUGCTokenExpired -= () => {
56-
KinetixCore.UGC.GetUgcUrl(OnUgcUrlFetched);
57-
};
57+
KinetixCore.UGC.OnUGCTokenExpired -= OnTokenExpired;
58+
KinetixCore.Account.OnDisconnectedAccount -= DisposeFetchUgcUrl;
5859
base.OnDestroy();
5960
}
6061

62+
private void FetchUgcUrl()
63+
{
64+
if (isFetching)
65+
return;
66+
67+
if (!Visible)
68+
return;
69+
70+
KinetixCore.UGC.GetUgcUrl(OnUgcUrlFetched);
71+
isFetching = true;
72+
}
73+
74+
private void OnTokenExpired()
75+
{
76+
isFetching = false;
77+
FetchUgcUrl();
78+
}
79+
80+
private void DisposeFetchUgcUrl()
81+
{
82+
isFetching = false;
83+
84+
if (texture != null)
85+
Destroy(texture);
86+
87+
if (qrCodeImage.sprite != null)
88+
Destroy(qrCodeImage.sprite);
89+
90+
qrCodeImage.gameObject.SetActive(false);
91+
}
92+
6193
public void CreateQRCode()
6294
{
6395
// Check if UGC are available
6496
if (!KinetixCore.UGC.IsUGCAvailable())
6597
return;
6698

67-
KinetixCore.UGC.GetUgcUrl(OnUgcUrlFetched);
99+
FetchUgcUrl();
68100
}
69101

70102
private void OnUgcUrlFetched(string _UgcUrl)
71103
{
72-
73104
ugcURL = _UgcUrl;
74105

75106
// Destroy texture and sprite if they exists
76-
if(texture != null)
77-
Texture2D.Destroy(texture);
78-
79-
if(qrCodeImage.sprite != null)
80-
Sprite.Destroy(qrCodeImage.sprite);
81-
107+
if (texture != null)
108+
Destroy(texture);
109+
110+
if (qrCodeImage.sprite != null)
111+
Destroy(qrCodeImage.sprite);
112+
113+
if (_UgcUrl == null)
114+
return;
115+
82116
texture = KinetixQRCodeHelper.Instance.GetQRCodeForUrl(ugcURL, dominantColor, highlightColor);
83117

84118
// Display a QRCOde
85119
qrCodeImage.gameObject.SetActive(true);
86120
qrCodeImage.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
87121

88-
// Then start polling to know if new emote is create
89-
KinetixCore.UGC.StartPollingForUGC();
90-
91122
// And start polling to know if the token is still available
92123
KinetixCore.UGC.StartPollingForNewUGCToken();
93-
94-
//launch TimeOut, that refresh the QRCode if it has been updated
95-
if(timeOutCoroutine != null)
96-
CoroutineUtils.Instance.StopCoroutine(timeOutCoroutine);
97-
98-
timeOutCoroutine = CoroutineUtils.Instance.StartCoroutine( TimeOutUgcUrl( KinetixConstants.c_TimeOutCreateQRCode) );
99-
100-
}
101-
102-
private IEnumerator TimeOutUgcUrl(float seconds)
103-
{
104-
yield return new WaitForSecondsRealtime(seconds);
105-
106-
timeOutCoroutine = null;
107-
if (Visible)
108-
{
109-
CreateQRCode();
110-
}
111124
}
112125

113126
private void OnCopyLinkToClipboard()

Samples~/1-QuickStart/QuickStart.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ namespace Kinetix.Sample
1313
{
1414
public class QuickStart : MonoBehaviour
1515
{
16-
[SerializeField] private string virtualWorldKey;
16+
[SerializeField] private string gameAPIKey;
1717
[SerializeField] private Animator localPlayerAnimator;
1818

1919
private void Awake()
2020
{
2121
KinetixCore.OnInitialized += OnKinetixInitialized;
2222
KinetixCore.Initialize(new KinetixCoreConfiguration()
2323
{
24-
VirtualWorldKey = virtualWorldKey,
24+
GameAPIKey = gameAPIKey,
2525
PlayAutomaticallyAnimationOnAnimators = true,
2626
ShowLogs = true,
2727
EnableAnalytics = true

Samples~/2-Events/Events.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ namespace Kinetix.Sample
77
{
88
public class Events : MonoBehaviour
99
{
10-
[SerializeField] private string virtualWorldKey;
10+
[SerializeField] private string gameAPIKey;
1111
[SerializeField] private Animator localPlayerAnimator;
1212

1313
private void Awake()
1414
{
1515
KinetixCore.OnInitialized += OnKinetixInitialized;
1616
KinetixCore.Initialize(new KinetixCoreConfiguration()
1717
{
18-
VirtualWorldKey = virtualWorldKey,
18+
GameAPIKey = gameAPIKey,
1919
PlayAutomaticallyAnimationOnAnimators = true,
2020
ShowLogs = true,
2121
EnableAnalytics = true

Samples~/3-LegacyAnimationClip/LegacyAnimationClip.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Kinetix.Sample
77
{
88
public class LegacyAnimationClip : MonoBehaviour
99
{
10-
[SerializeField] private string virtualWorldKey;
10+
[SerializeField] private string gameAPIKey;
1111
[SerializeField] private GameObject character;
1212
[SerializeField] private Avatar avatar;
1313
[SerializeField] private Transform rootTransform;
@@ -19,7 +19,7 @@ private void Awake()
1919
KinetixCore.OnInitialized += OnKinetixInitialized;
2020
KinetixCore.Initialize(new KinetixCoreConfiguration()
2121
{
22-
VirtualWorldKey = virtualWorldKey,
22+
GameAPIKey = gameAPIKey,
2323
PlayAutomaticallyAnimationOnAnimators = true,
2424
ShowLogs = true,
2525
EnableAnalytics = true

Samples~/4-AnimationQueue/AnimationQueue.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ namespace Kinetix.Sample
88
{
99
public class AnimationQueue : MonoBehaviour
1010
{
11-
[SerializeField] private string virtualWorldKey;
11+
[SerializeField] private string gameAPIKey;
1212
[SerializeField] private Animator localPlayerAnimator;
1313

1414
private void Awake()
1515
{
1616
KinetixCore.OnInitialized += OnKinetixInitialized;
1717
KinetixCore.Initialize(new KinetixCoreConfiguration()
1818
{
19-
VirtualWorldKey = virtualWorldKey,
19+
GameAPIKey = gameAPIKey,
2020
PlayAutomaticallyAnimationOnAnimators = true,
2121
ShowLogs = true
2222
});

Samples~/5-Translation/Translation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ namespace Kinetix.Sample
1313
{
1414
public class Translation : MonoBehaviour
1515
{
16-
[SerializeField] private string virtualWorldKey;
16+
[SerializeField] private string gameAPIKey;
1717
[SerializeField] private Animator localPlayerAnimator;
1818

1919
private void Awake()
2020
{
2121
KinetixCore.OnInitialized += OnKinetixInitialized;
2222
KinetixCore.Initialize(new KinetixCoreConfiguration()
2323
{
24-
VirtualWorldKey = virtualWorldKey,
24+
GameAPIKey = gameAPIKey,
2525
PlayAutomaticallyAnimationOnAnimators = true,
2626
ShowLogs = true,
2727
EnableAnalytics = true

Samples~/6-Theme/Theme.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Kinetix.Sample
1515
{
1616
public class Theme : MonoBehaviour
1717
{
18-
[SerializeField] private string virtualWorldKey;
18+
[SerializeField] private string gameAPIKey;
1919
[SerializeField] private Animator localPlayerAnimator;
2020
[SerializeField] private KinetixCustomTheme kinetixCustomTheme;
2121
[SerializeField] private ECustomTheme defaultConfig = ECustomTheme.DARK_MODE;
@@ -28,7 +28,7 @@ private void Awake()
2828
KinetixCore.OnInitialized += OnKinetixInitialized;
2929
KinetixCore.Initialize(new KinetixCoreConfiguration()
3030
{
31-
VirtualWorldKey = virtualWorldKey,
31+
GameAPIKey = gameAPIKey,
3232
PlayAutomaticallyAnimationOnAnimators = true,
3333
ShowLogs = true,
3434
EnableAnalytics = true

Samples~/7-Inputs/Inputs.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Kinetix.Sample
1313
{
1414
public class Inputs : MonoBehaviour
1515
{
16-
[SerializeField] private string virtualWorldKey;
16+
[SerializeField] private string gameAPIKey;
1717
[SerializeField] private Animator localPlayerAnimator;
1818
[SerializeField] private KinetixInputMapSO kinetixCustomInputActionMap;
1919

@@ -22,7 +22,7 @@ private void Awake()
2222
KinetixCore.OnInitialized += OnKinetixInitialized;
2323
KinetixCore.Initialize(new KinetixCoreConfiguration()
2424
{
25-
VirtualWorldKey = virtualWorldKey,
25+
GameAPIKey = gameAPIKey,
2626
PlayAutomaticallyAnimationOnAnimators = true,
2727
ShowLogs = false,
2828
EnableAnalytics = false

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.kinetix.uiemotewheel",
3-
"version": "1.0.1",
3+
"version": "1.1.0",
44
"displayName": "Kinetix UI Emote Wheel",
55
"description": "Kinetix UI Emote Wheel components and interactions",
66
"samples": [

0 commit comments

Comments
 (0)