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

Moved Boilerplates to Samples directory #259

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
/[Aa]ssets/Samples
/[Aa]ssets/Samples~/Setup/Resources/SequenceConfig.asset
/[Aa]ssets/Samples.meta
!/Packages/Sequence-Unity/Sequence/Samples~/

# Recordings can get excessive in size
/[Rr]ecordings/
Expand Down
Binary file modified Demo/Build/Demo.data.unityweb
Binary file not shown.
Binary file modified Demo/Build/Demo.framework.js.unityweb
Binary file not shown.
Binary file modified Demo/Build/Demo.wasm.unityweb
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,24 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 2b585c6ea5ce547c3b5638accfd28750, type: 3}
--- !u!1 &8507087844847162024 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 8673935661200349505, guid: 2b585c6ea5ce547c3b5638accfd28750, type: 3}
m_PrefabInstance: {fileID: 1040118026321005545}
m_PrefabAsset: {fileID: 0}
--- !u!114 &9016821820083042173
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8507087844847162024}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e82dd5f4f6624e9caa5b03040ae2e6f2, type: 3}
m_Name:
m_EditorClassIdentifier:
<Key>k__BackingField: rewards
--- !u!224 &8507087844847162025 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 8673935661200349504, guid: 2b585c6ea5ce547c3b5638accfd28750, type: 3}
Expand Down Expand Up @@ -543,6 +561,24 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 2b585c6ea5ce547c3b5638accfd28750, type: 3}
--- !u!1 &8507087845319554736 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 8673935661200349505, guid: 2b585c6ea5ce547c3b5638accfd28750, type: 3}
m_PrefabInstance: {fileID: 1040118026787106801}
m_PrefabAsset: {fileID: 0}
--- !u!114 &5618924209557467099
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8507087845319554736}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e82dd5f4f6624e9caa5b03040ae2e6f2, type: 3}
m_Name:
m_EditorClassIdentifier:
<Key>k__BackingField: inventory
--- !u!224 &8507087845319554737 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 8673935661200349504, guid: 2b585c6ea5ce547c3b5638accfd28750, type: 3}
Expand Down Expand Up @@ -725,6 +761,24 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 2b585c6ea5ce547c3b5638accfd28750, type: 3}
--- !u!1 &8507087846269709678 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 8673935661200349505, guid: 2b585c6ea5ce547c3b5638accfd28750, type: 3}
m_PrefabInstance: {fileID: 1040118027733070895}
m_PrefabAsset: {fileID: 0}
--- !u!114 &3940918403346717788
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8507087846269709678}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e82dd5f4f6624e9caa5b03040ae2e6f2, type: 3}
m_Name:
m_EditorClassIdentifier:
<Key>k__BackingField: shop
--- !u!224 &8507087846269709679 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 8673935661200349504, guid: 2b585c6ea5ce547c3b5638accfd28750, type: 3}
Expand Down Expand Up @@ -912,6 +966,24 @@ RectTransform:
m_CorrespondingSourceObject: {fileID: 8673935661200349504, guid: 2b585c6ea5ce547c3b5638accfd28750, type: 3}
m_PrefabInstance: {fileID: 1040118028080684160}
m_PrefabAsset: {fileID: 0}
--- !u!1 &8507087846678070721 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 8673935661200349505, guid: 2b585c6ea5ce547c3b5638accfd28750, type: 3}
m_PrefabInstance: {fileID: 1040118028080684160}
m_PrefabAsset: {fileID: 0}
--- !u!114 &3831913060059352397
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8507087846678070721}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e82dd5f4f6624e9caa5b03040ae2e6f2, type: 3}
m_Name:
m_EditorClassIdentifier:
<Key>k__BackingField: profile
--- !u!1001 &3739462950292767288
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1094,3 +1166,21 @@ RectTransform:
m_CorrespondingSourceObject: {fileID: 8673935661200349504, guid: 2b585c6ea5ce547c3b5638accfd28750, type: 3}
m_PrefabInstance: {fileID: 3739462950292767288}
m_PrefabAsset: {fileID: 0}
--- !u!1 &5441825245782596473 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 8673935661200349505, guid: 2b585c6ea5ce547c3b5638accfd28750, type: 3}
m_PrefabInstance: {fileID: 3739462950292767288}
m_PrefabAsset: {fileID: 0}
--- !u!114 &7948092023586004144
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5441825245782596473}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e82dd5f4f6624e9caa5b03040ae2e6f2, type: 3}
m_Name:
m_EditorClassIdentifier:
<Key>k__BackingField: sign

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,14 @@ MonoBehaviour:
_collectionAddress: 0xd2926e2ee243e8df781ab907b48f77ec5d7a8be1
_saleContractAddress: 0x476f14887372e21fea64baba11c849b518a2e928
_itemsForSale: 010000000200000003000000
_defaultFeatures: http://localhost:4444
_featureSelection: {fileID: 1094787527}
_featureButtons:
- {fileID: 1040118027007171566}
- {fileID: 1040118027007171565}
- {fileID: 1040118027007171564}
- {fileID: 1040118027007171563}
- {fileID: 1040118027007171562}
--- !u!1 &220330147
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1346,3 +1353,58 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e8835adb06f3742d1bf6de43dcf4489f, type: 3}
--- !u!114 &1040118027007171562 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 7948092023586004144, guid: e8835adb06f3742d1bf6de43dcf4489f, type: 3}
m_PrefabInstance: {fileID: 1040118027007171561}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e82dd5f4f6624e9caa5b03040ae2e6f2, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1040118027007171563 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 3940918403346717788, guid: e8835adb06f3742d1bf6de43dcf4489f, type: 3}
m_PrefabInstance: {fileID: 1040118027007171561}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e82dd5f4f6624e9caa5b03040ae2e6f2, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1040118027007171564 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 5618924209557467099, guid: e8835adb06f3742d1bf6de43dcf4489f, type: 3}
m_PrefabInstance: {fileID: 1040118027007171561}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e82dd5f4f6624e9caa5b03040ae2e6f2, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1040118027007171565 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 9016821820083042173, guid: e8835adb06f3742d1bf6de43dcf4489f, type: 3}
m_PrefabInstance: {fileID: 1040118027007171561}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e82dd5f4f6624e9caa5b03040ae2e6f2, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1040118027007171566 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 3831913060059352397, guid: e8835adb06f3742d1bf6de43dcf4489f, type: 3}
m_PrefabInstance: {fileID: 1040118027007171561}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e82dd5f4f6624e9caa5b03040ae2e6f2, type: 3}
m_Name:
m_EditorClassIdentifier:
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Sequence.EmbeddedWallet;
using Sequence.Utils.SecureStorage;
using UnityEngine;
using UnityEngine.Events;

namespace Sequence.Boilerplates
{
Expand All @@ -16,21 +17,24 @@ public class BoilerplateController : MonoBehaviour
[SerializeField] private string _collectionAddress;
[SerializeField] private string _saleContractAddress;
[SerializeField] private int[] _itemsForSale;
[SerializeField] private string _defaultFeatures;

[Header("Components")]
[SerializeField] private GameObject _featureSelection;
[SerializeField] private FeatureSelectionButton[] _featureButtons;

private IWallet _wallet;
private SequenceLoginWindow _loginWindow;
private SequencePlayerProfile _playerProfile;
private UnityAction _openDefaultWindow;

private void Awake()
{
SequenceWallet.OnFailedToRecoverSession += OnFailedToRecoverSession;
SequenceWallet.OnWalletCreated += wallet =>
{
_wallet = wallet;
ShowFeatureSelection();
ShowDefaultWindow();

if (_loginWindow)
_loginWindow.Hide();
Expand All @@ -40,7 +44,7 @@ private void Awake()
if (s == wallet.SessionId)
{
if (_playerProfile)
_playerProfile.Hide();
_playerProfile.gameObject.SetActive(false);

TryRecoverSessionToOpenLoginWindow();
}
Expand All @@ -50,6 +54,7 @@ private void Awake()

private void Start()
{
EnableFeatures();
TryRecoverSessionToOpenLoginWindow();
}

Expand All @@ -61,32 +66,42 @@ private void OnDestroy()
public void OpenPlayerProfilePanel()
{
HideFeatureSelection();
_playerProfile = BoilerplateFactory.OpenSequencePlayerProfile(transform, _wallet, _chain, ShowFeatureSelection);
_playerProfile = BoilerplateFactory.OpenSequencePlayerProfile(transform, _wallet, _chain, ShowDefaultWindow);
}

public void OpenDailyRewardsPanel()
{
HideFeatureSelection();
BoilerplateFactory.OpenSequenceDailyRewards(transform, _wallet, _chain, _dailyRewardsApi, ShowFeatureSelection);
BoilerplateFactory.OpenSequenceDailyRewards(transform, _wallet, _chain, _dailyRewardsApi, ShowDefaultWindow);
}

public void OpenInventoryPanel()
{
HideFeatureSelection();
BoilerplateFactory.OpenSequenceInventory(transform, _wallet, _chain, _collectionAddress, ShowFeatureSelection);
BoilerplateFactory.OpenSequenceInventory(transform, _wallet, _chain, _collectionAddress, ShowDefaultWindow);
}

public void OpenInGameShopPanel()
{
HideFeatureSelection();
BoilerplateFactory.OpenSequenceInGameShop(transform, _wallet, _chain, _collectionAddress,
_saleContractAddress, _itemsForSale, ShowFeatureSelection);
_saleContractAddress, _itemsForSale, ShowDefaultWindow);
}

public void OpenSignMessage()
{
HideFeatureSelection();
BoilerplateFactory.OpenSequenceSignMessage(transform, _wallet, _chain, ShowFeatureSelection);
BoilerplateFactory.OpenSequenceSignMessage(transform, _wallet, _chain, ShowDefaultWindow);
}

private void SetDefaultWindow(UnityAction openDefaultWindow)
{
_openDefaultWindow = openDefaultWindow;
}

private void ShowDefaultWindow()
{
_openDefaultWindow?.Invoke();
}

private void ShowFeatureSelection()
Expand Down Expand Up @@ -122,5 +137,48 @@ private void OnFailedToRecoverSession(string error)
Debug.LogError($"Error attempting to recover Sequence session: {error}");
_loginWindow = BoilerplateFactory.OpenSequenceLoginWindow(transform);
}

private void EnableFeatures()
{
var features = GetFeatures();
if (features.Length == 1)
{
var feature = features[0];
var button = Array.Find(_featureButtons, b => b.Key == feature);
SetDefaultWindow(button.ExecuteClick);
}
else
{
SetDefaultWindow(ShowFeatureSelection);
Array.ForEach(_featureButtons, b => b.EnableIfExists(features));
}
}

private string[] GetFeatures()
{
#if !UNITY_EDITOR && UNITY_WEBGL
var url = Application.absoluteURL;
#else
var url = _defaultFeatures;
#endif

if (string.IsNullOrEmpty(url))
return Array.Empty<string>();

try
{
var uri = new Uri(url);
var parts = uri.Query.Split("features=");
if (parts.Length != 2)
throw new Exception();

return parts[1].Split("+");
}
catch (Exception e)
{
Debug.LogException(e);
return Array.Empty<string>();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

namespace Sequence.Boilerplates
{
[RequireComponent(typeof(Button))]
public class FeatureSelectionButton : MonoBehaviour
{
public UnityAction ExecuteClick => () => GetComponent<Button>().onClick?.Invoke();

[field: SerializeField] public string Key { get; private set; }

public void EnableIfExists(string[] allFeatures)
{
gameObject.SetActive(allFeatures.Length == 0 || Array.Exists(allFeatures, f => f == Key));
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading