Skip to content

Commit 7aa6b67

Browse files
AlmightyMikkelkirre-bylund
authored andcommitted
fix: ui information on failed purchases
1 parent a44e586 commit 7aa6b67

File tree

6 files changed

+161
-16
lines changed

6 files changed

+161
-16
lines changed

Samples.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.

Samples~/LootLockerExamples/8 - Virtual Currency Purchases/8 - Virtual Currency Purchases.unity

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ RectTransform:
155155
- {fileID: 995902235}
156156
- {fileID: 1378087828}
157157
- {fileID: 270986421}
158+
- {fileID: 960046285}
158159
m_Father: {fileID: 2137498241}
159160
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
160161
m_AnchorMin: {x: 0.5, y: 0.5}
@@ -538,6 +539,85 @@ Transform:
538539
m_Children: []
539540
m_Father: {fileID: 0}
540541
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
542+
--- !u!1 &960046284
543+
GameObject:
544+
m_ObjectHideFlags: 0
545+
m_CorrespondingSourceObject: {fileID: 0}
546+
m_PrefabInstance: {fileID: 0}
547+
m_PrefabAsset: {fileID: 0}
548+
serializedVersion: 6
549+
m_Component:
550+
- component: {fileID: 960046285}
551+
- component: {fileID: 960046287}
552+
- component: {fileID: 960046286}
553+
m_Layer: 5
554+
m_Name: WarningText
555+
m_TagString: Untagged
556+
m_Icon: {fileID: 0}
557+
m_NavMeshLayer: 0
558+
m_StaticEditorFlags: 0
559+
m_IsActive: 0
560+
--- !u!224 &960046285
561+
RectTransform:
562+
m_ObjectHideFlags: 0
563+
m_CorrespondingSourceObject: {fileID: 0}
564+
m_PrefabInstance: {fileID: 0}
565+
m_PrefabAsset: {fileID: 0}
566+
m_GameObject: {fileID: 960046284}
567+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
568+
m_LocalPosition: {x: 0, y: 0, z: 0}
569+
m_LocalScale: {x: 1, y: 1, z: 1}
570+
m_ConstrainProportionsScale: 0
571+
m_Children: []
572+
m_Father: {fileID: 134234552}
573+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
574+
m_AnchorMin: {x: 0.5, y: 0.5}
575+
m_AnchorMax: {x: 0.5, y: 0.5}
576+
m_AnchoredPosition: {x: 0, y: 0}
577+
m_SizeDelta: {x: 546.0061, y: 30}
578+
m_Pivot: {x: 0.5, y: 0.5}
579+
--- !u!114 &960046286
580+
MonoBehaviour:
581+
m_ObjectHideFlags: 0
582+
m_CorrespondingSourceObject: {fileID: 0}
583+
m_PrefabInstance: {fileID: 0}
584+
m_PrefabAsset: {fileID: 0}
585+
m_GameObject: {fileID: 960046284}
586+
m_Enabled: 1
587+
m_EditorHideFlags: 0
588+
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
589+
m_Name:
590+
m_EditorClassIdentifier:
591+
m_Material: {fileID: 0}
592+
m_Color: {r: 1, g: 0, b: 0, a: 1}
593+
m_RaycastTarget: 1
594+
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
595+
m_Maskable: 1
596+
m_OnCullStateChanged:
597+
m_PersistentCalls:
598+
m_Calls: []
599+
m_FontData:
600+
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
601+
m_FontSize: 14
602+
m_FontStyle: 0
603+
m_BestFit: 0
604+
m_MinSize: 10
605+
m_MaxSize: 40
606+
m_Alignment: 1
607+
m_AlignByGeometry: 0
608+
m_RichText: 1
609+
m_HorizontalOverflow: 0
610+
m_VerticalOverflow: 0
611+
m_LineSpacing: 1
612+
m_Text: New Text
613+
--- !u!222 &960046287
614+
CanvasRenderer:
615+
m_ObjectHideFlags: 0
616+
m_CorrespondingSourceObject: {fileID: 0}
617+
m_PrefabInstance: {fileID: 0}
618+
m_PrefabAsset: {fileID: 0}
619+
m_GameObject: {fileID: 960046284}
620+
m_CullTransparentMesh: 1
541621
--- !u!1 &995902234
542622
GameObject:
543623
m_ObjectHideFlags: 0
@@ -782,6 +862,7 @@ GameObject:
782862
m_Component:
783863
- component: {fileID: 1738309042}
784864
- component: {fileID: 1738309041}
865+
- component: {fileID: 1738309043}
785866
m_Layer: 0
786867
m_Name: StoreManager
787868
m_TagString: Untagged
@@ -821,6 +902,19 @@ Transform:
821902
m_Children: []
822903
m_Father: {fileID: 0}
823904
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
905+
--- !u!114 &1738309043
906+
MonoBehaviour:
907+
m_ObjectHideFlags: 0
908+
m_CorrespondingSourceObject: {fileID: 0}
909+
m_PrefabInstance: {fileID: 0}
910+
m_PrefabAsset: {fileID: 0}
911+
m_GameObject: {fileID: 1738309040}
912+
m_Enabled: 1
913+
m_EditorHideFlags: 0
914+
m_Script: {fileID: 11500000, guid: 50833270f1d5a964788595988deae554, type: 3}
915+
m_Name:
916+
m_EditorClassIdentifier:
917+
warningText: {fileID: 960046286}
824918
--- !u!1 &1854692668
825919
GameObject:
826920
m_ObjectHideFlags: 0

Samples~/LootLockerExamples/8 - Virtual Currency Purchases/LootLockerVirtualStore.cs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public void FetchPlayerWallet(string ulid)
5353
}
5454

5555
walletID = response.id;
56-
GetPlayerGold();
5756
GiveGold();
57+
5858
});
5959
}
6060

@@ -68,6 +68,12 @@ public void GetPlayerGold()
6868
return;
6969
}
7070

71+
//Default to hard coded variables
72+
if(response.balances.Length <= 0)
73+
{
74+
currencyCode = "GLD: ";
75+
return;
76+
}
7177
currencyCode = response.balances[0].currency.code.ToUpper() + ": ";
7278

7379
goldAmount.text = currencyCode + response.balances[0].amount;
@@ -85,21 +91,8 @@ public void FetchVirtualProductsFromCatalog()
8591
return;
8692
}
8793

88-
8994
foreach (var item in response.entries)
90-
{
91-
92-
switch(item.entity_kind){
93-
case LootLockerEnums.LootLockerCatalogEntryEntityKind.asset:
94-
var something = response.asset_details[item.GetItemDetailsKey()];
95-
Debug.Log(something.name);
96-
break;
97-
98-
}
99-
100-
101-
102-
95+
{
10396
Debug.Log("Item: " + item.entity_name + " | " + item.prices[0].display_amount);
10497
var obj = Instantiate(virtualPurchaseProductPrefab, storeUI);
10598
obj.GetComponent<VirtualPurchaseProduct>().CreateProduct(item.entity_name,
@@ -120,6 +113,7 @@ public void GiveGold()
120113
}
121114

122115
goldAmount.text = currencyCode + response.amount;
116+
GetPlayerGold();
123117
});
124118
}
125119
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using UnityEngine.UI;
5+
6+
public class LootLockerVirtualStoreWarner : MonoBehaviour
7+
{
8+
9+
public static LootLockerVirtualStoreWarner Instance;
10+
11+
[SerializeField] private Text warningText;
12+
13+
private void Awake()
14+
{
15+
if (Instance == null)
16+
Instance = this;
17+
else
18+
Destroy(this.gameObject);
19+
}
20+
21+
22+
public void ShowText(string text)
23+
{
24+
warningText.text = text;
25+
StartCoroutine(ShowText());
26+
}
27+
28+
public IEnumerator ShowText()
29+
{
30+
warningText.gameObject.SetActive(true);
31+
32+
yield return new WaitForSeconds(6);
33+
34+
warningText.gameObject.SetActive(false);
35+
}
36+
37+
38+
}

Samples~/LootLockerExamples/8 - Virtual Currency Purchases/LootLockerVirtualStoreWarner.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.

Samples~/LootLockerExamples/8 - Virtual Currency Purchases/VirtualPurchaseProduct.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void Purchase()
2525
{
2626
if (!response.success)
2727
{
28-
Debug.Log("Could not buy catalog item");
28+
LootLockerVirtualStoreWarner.Instance.ShowText(response.errorData.message);
2929
return;
3030
}
3131

0 commit comments

Comments
 (0)