Skip to content

Commit

Permalink
Merge pull request #24 from alturanft/new_version
Browse files Browse the repository at this point in the history
Fixed bugs
  • Loading branch information
mranoncoder authored Feb 15, 2023
2 parents c1bd3f4 + fe7df3c commit 9ab0832
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public void GetUsersItemFunction()
GetUsersItems
.Initialize(destroyAtEnd: true)
.SetAddress(
_address.text.ToString()
_Itemaddress.text.ToString()
).OnError(error => Debug.Log(error))
.OnComplete(result => setItemData(result)
)
Expand Down
10 changes: 9 additions & 1 deletion Documentation/AlturaNFT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@

Using our Unity SDK, you are able to interact with Altura services such as authenticating users using Altura Guard,get Users information and items, get items and collection information.

> <b>In this documentation we only explain the Sample scene and teach you how you can use them, To learn more about the AlturaNFT SDK function, please visit our official documentation:</b> \
> <b>In this documentation we only explain how you can import the Sample scene to your project, To learn more about the AlturaNFT SDK function, please visit our official documentation:</b> \
> https://docs.alturanft.com/altura-documentation/unity-sdk-reference/installation
## Import Sample scene

1. Open the Package Manager window (Window > Package Manager)
2. Select the 'Packages: In Project' tab
3. Select the 'Altura Web3' package
4. Under the 'Samples' section of the window, select 'Import'
5. The sample can then be found under Assets/Samples/Altura Web3/1.0.6/AlturaDemo
5 changes: 0 additions & 5 deletions Editor/AlturaNFTSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,12 @@ static void GuiLine( int i_height = 1 )

#region ReadWrite UserPrefs

private static AlturaUser.UserPrefs _userPrefs = new AlturaUser.UserPrefs();
private static TextAsset targetFile;
static void ReadFromUserPrefs()
{
targetFile = Resources.Load<TextAsset>("AlturaNFT UserPrefs");
if (targetFile != null)
{
_userPrefs = JsonConvert.DeserializeObject<AlturaUser.UserPrefs>(targetFile.text);
myAPIString = _userPrefs.API_KEY;
AlturaUser.SaveNewApi(myAPIString);
AlturaUser.Initialise();
UserStats();
}
Expand All @@ -338,7 +334,6 @@ static void ReadFromUserPrefs()
}
void WriteToUserPrefs()
{
AlturaUser.SaveNewApi(myAPIString);
base.SaveChanges();
}

Expand Down
2 changes: 1 addition & 1 deletion Runtime/AuthenticateUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class AuthenticateUser : MonoBehaviour
public UnityEvent afterError;

[Header("Run Component when this Game Object is Set Active")]
[SerializeField] private bool onEnable = true;
[SerializeField] private bool onEnable = false;
public bool debugErrorLog = true;
public bool debugLogRawApiResponse = true;

Expand Down
2 changes: 0 additions & 2 deletions Runtime/GetCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ public class GetCollection : MonoBehaviour

private void Awake()
{
AlturaUser.Initialise();
_apiKey = AlturaUser.GetUserApiKey();

}

Expand Down
2 changes: 1 addition & 1 deletion Runtime/GetCollections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class GetCollections : MonoBehaviour
public UnityEvent afterError;

[Header("Run Component when this Game Object is Set Active")]
[SerializeField] private bool onEnable = true;
[SerializeField] private bool onEnable = false;
public bool debugErrorLog = true;
public bool debugLogRawApiResponse = true;

Expand Down
2 changes: 1 addition & 1 deletion Runtime/GetHistory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class GetHistory : MonoBehaviour
public UnityEvent afterError;

[Header("Run Component when this Game Object is Set Active")]
[SerializeField] private bool onEnable = true;
[SerializeField] private bool onEnable = false;
public bool debugErrorLog = true;
public bool debugLogRawApiResponse = true;

Expand Down
2 changes: 1 addition & 1 deletion Runtime/GetHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class GetHolder : MonoBehaviour
public UnityEvent afterError;

[Header("Run Component when this Game Object is Set Active")]
[SerializeField] private bool onEnable = true;
[SerializeField] private bool onEnable = false;
public bool debugErrorLog = true;
public bool debugLogRawApiResponse = true;

Expand Down
2 changes: 1 addition & 1 deletion Runtime/GetItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class GetItem : MonoBehaviour
public UnityEvent afterError;

[Header("Run Component when this Game Object is Set Active")]
[SerializeField] private bool onEnable = true;
[SerializeField] private bool onEnable = false;
public bool debugErrorLog = true;
public bool debugLogRawApiResponse = true;

Expand Down
2 changes: 1 addition & 1 deletion Runtime/GetItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public enum Chains
public UnityEvent afterError;

[Header("Run Component when this Game Object is Set Active")]
[SerializeField] private bool onEnable = true;
[SerializeField] private bool onEnable = false;
public bool debugErrorLog = true;
public bool debugLogRawApiResponse = true;

Expand Down
18 changes: 13 additions & 5 deletions Runtime/GetUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class GetUser : MonoBehaviour
public UnityEvent afterError;

[Header("Run Component when this Game Object is Set Active")]
[SerializeField] private bool onEnable = true;
[SerializeField] private bool onEnable = false;
public bool debugErrorLog = true;
public bool debugLogRawApiResponse = true;

Expand Down Expand Up @@ -70,10 +70,18 @@ private void OnEnable()

public static GetUser Initialize(bool destroyAtEnd = true)
{
var _this = new GameObject(AlturaConstants.FeatureName_GetUser).AddComponent<GetUser>();
_this.destroyAtEnd = destroyAtEnd;
_this.onEnable = false;
_this.debugErrorLog = false;

Debug.Log("Hi");
var _this = new GameObject(AlturaConstants.FeatureName_GetUser).AddComponent<GetUser>();

Debug.Log("Hi2");
_this.destroyAtEnd = destroyAtEnd;

Debug.Log("Hi3");
_this.onEnable = false;

Debug.Log("Hi4");
_this.debugErrorLog = false;
return _this;
}

Expand Down
2 changes: 1 addition & 1 deletion Runtime/GetUserBalance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class GetUserBalance : MonoBehaviour
public UnityEvent afterError;

[Header("Run Component when this Game Object is Set Active")]
[SerializeField] private bool onEnable = true;
[SerializeField] private bool onEnable = false;
public bool debugErrorLog = true;
public bool debugLogRawApiResponse = true;

Expand Down
2 changes: 1 addition & 1 deletion Runtime/GetUserERC20Balance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class GetUserERC20Balance : MonoBehaviour
public UnityEvent afterError;

[Header("Run Component when this Game Object is Set Active")]
[SerializeField] private bool onEnable = true;
[SerializeField] private bool onEnable = false;
public bool debugErrorLog = true;
public bool debugLogRawApiResponse = true;

Expand Down
2 changes: 1 addition & 1 deletion Runtime/GetUserItemBalance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class GetUserItemBalance : MonoBehaviour
public UnityEvent afterError;

[Header("Run Component when this Game Object is Set Active")]
[SerializeField] private bool onEnable = true;
[SerializeField] private bool onEnable = false;
public bool debugErrorLog = true;
public bool debugLogRawApiResponse = true;

Expand Down
2 changes: 1 addition & 1 deletion Runtime/GetUsers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class GetUsers : MonoBehaviour
public UnityEvent afterError;

[Header("Run Component when this Game Object is Set Active")]
[SerializeField] private bool onEnable = true;
[SerializeField] private bool onEnable = false;
public bool debugErrorLog = true;
public bool debugLogRawApiResponse = true;

Expand Down
97 changes: 1 addition & 96 deletions Runtime/Internal/AlturaUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,97 +17,17 @@ namespace AlturaNFT.Internal

public static class AlturaUser
{
[System.Serializable]
public class UserPrefs {
public string API_KEY;
}

public static bool _initialised = false;
private static UserPrefs _userPrefs = new UserPrefs();

public static void Initialise()
{
if(_initialised == false)
{
_userPrefs = getUserPrefs();
#if UNITY_EDITOR
CheckAlturaPkg.OnListCheckComplete(isUPM => src.UPMImport = isUPM.ToString());
CheckAlturaPkg.CheckPkgList();
#endif
}

}


#region Prefs File Write
#if UNITY_EDITOR
public static void SaveNewApi(string newAPI)
{
_userPrefs.API_KEY = newAPI;
SaveUserPrefs();
}


public static void SaveUserPrefs()
{
if (!AssetDatabase.IsValidFolder("Assets/AlturaNFT/Resources"))
{
CreateFolder();
}

WriteToUserPrefs();
}

static void WriteToUserPrefs()
{
_initialised = false;
string json = JsonUtility.ToJson(_userPrefs);
System.IO.File.WriteAllText("Assets/AlturaNFT/Resources/" + "AlturaNFT UserPrefs.json", json);
AssetDatabase.Refresh();
AlturaUser.Initialise();
}


static void CreateFolder()
{
AssetDatabase.CreateFolder("Assets", "AlturaNFT");
string guid = AssetDatabase.CreateFolder("Assets/AlturaNFT", "Resources");
string newFolderPath = AssetDatabase.GUIDToAssetPath(guid);
}

#endif
#endregion


#region Prefs File Read
static UserPrefs getUserPrefs()
{
string _userfile = LoadUserPrefsTextfile();
if (_userfile.Length != 0)
{
_initialised = true;
return JsonConvert.DeserializeObject<UserPrefs>(_userfile);
}
else
{
_initialised = false;
Debug.LogError("Unable to Initialise, Make sure to input your APIKEYS in AlturaNFT/Home in Unity Editor");
return null;
}
}

private static TextAsset targetFile;

public static string LoadUserPrefsTextfile()
{
targetFile = Resources.Load<TextAsset>("AlturaNFT UserPrefs");;
if (targetFile != null)
return targetFile.text;
else
return string.Empty;
}

#endregion


#region Get Set Gos

Expand Down Expand Up @@ -170,21 +90,6 @@ public static string GetSource()
return json;
}

public static string GetUserApiKey()
{
if (_initialised)
{
return _userPrefs.API_KEY;
}
else if(targetFile==null)
{

return String.Empty;
}
else
return " Make sure to input your APIKEYS in AlturaNFT/Home ";
}

#endregion

}
Expand Down

0 comments on commit 9ab0832

Please sign in to comment.