XenoPrfes in the UnityAsset Store! (Free)
New Version of Xenoprefs:
Hey, I have just finished the new Version of my Asset "XenoPrefs" on the Unity Asset Store!
Note that the current version is 1.3.
If the Version on the Asset store is still 1.2 you should wait for the version 1.3 to be online.
It should be online within the next days and you get it for free from here.
If you are interested in this package please take a minute and read this overview/"how to use":
Some notes first:
XenoPrefs was developed as a replacement for PlayerPrefs.
PlayerPrefs on Windows are stored in the Registry, have a long loading/writing time and are unencrypted (plain text).
With XenoPrefs my main goal was to fix these issues.
But i achieved not only that. XenoPrefs is very userfriendly and has some other smaller neat features
that make it more powerful than PlayerPrefs.
XenoPrefs was developed for the Windows Platform.
Although it should work on any other suported Platform just as well.
==Currently Supported: Windows Standalone, Linux Standalone, Android==
If you have any questions feel free to contact me.
Also if you find any bugs please report them to me: [email protected]
I hope you give it a try and enjoy using it.
How to use:
XenoPrefs:
XenoPrefs holds the main logic and does all the work for saving your data.
int Values:
Saving int Values:
You can use XenoPrefs.SetInt(string EntryName,int Value)
to Save an Integer.
Here is a small Example:
using UnityEngine;
public class PlayerStats : MonoBehaviour
{
public int health = 100; //health value
public void Start(){
//Saves 'PlayerHealth' with a value of 100 to XenoPrefs:
XenoPrefs.SetInt("PlayerHealth",this.health);
}
}
Loading int Values:
You can use XenoPrefs.GetInt(string EntryName, int defaultValue)
to load a saved int from XenoPrefs.
The method will return the defaultValue if the EntryName was not found in the Saves.
Here a small example for loading int Values:
using UnityEngine;
public class PlayerStats : MonoBehaviour
{
public int health;
public void Start(){
//Loads 'PlayerHealth' from XenoPrefs:
health = XenoPrefs.GetInt("PlayerHealth",100);
}
}
Float Values:
Saving float Values:
You can use XenoPrefs.SetFloat(string EntryName,float Value)
to Save a float value.
Here is a small Example:
using UnityEngine;
public class PlayerStats : MonoBehaviour
{
public float health = 100.0f; //health value
public void Start(){
//Saves 'PlayerHealth' with a value of 100.0f to XenoPrefs:
XenoPrefs.SetFloat("PlayerHealth",this.health);
}
}
Loading float Values:
You can use XenoPrefs.GetInt(string EntryName, float defaultValue)
to load a saved float from XenoPrefs.
The method will return the defaultValue if the EntryName was not found in the Saves.
Here a small example for loading float Values:
using UnityEngine;
public class PlayerStats : MonoBehaviour
{
public float health;
public void Start(){
//Loads 'PlayerHealth' from XenoPrefs:
health = XenoPrefs.GetFloat("PlayerHealth",100.0f);
}
}
String Values:
Saving string Values:
You can use XenoPrefs.SetInt(string EntryName,string Value)
to Save a String.
Here is a small Example:
using UnityEngine;
public class PlayerStats : MonoBehaviour
{
public string name = "Erarnitox";
public void Start(){
//Saves 'PlayerName' with a value of "Erarnitox" to XenoPrefs:
XenoPrefs.SetString("PlayerName",this.health);
}
}
Loading string Values:
You can use XenoPrefs.GetString(string EntryName, string defaultValue)
to load a saved string from XenoPrefs.
The method will return the defaultValue if the EntryName was not found in the Saves.
Here a small example for loading int Values:
using UnityEngine;
public class PlayerStats : MonoBehaviour
{
public string name;
public void Start(){
//Loads 'PlayerName' from XenoPrefs:
name = XenoPrefs.GetString("PlayerName","Player");
}
}
Save to file:
You can use XenoPrefs.Save()
to save everything you saved using XenoPrefs into a Savefile.
You dont have to call this method manually. By default XenoSaver will call this method automaticly
when the game closes for you.
But you can disable this option of XenoSaver and call XenoPrefs.Save()
manually
(Could be useful for checkpoints in game)
Note: Savefile will be encrypted.
Load from file:
You can use XenoPrefs.ReLoad()
to (re-)load your data from the Savefile.
Check for Entry:
You can use XenoPrefs.HasEntry()
to check if any entry exists.
You can use XenoPrefs.HasEntry(string EntryName)
to check if an entry with EntryName exists.
A small Example:
using UnityEngine;
public class EntryTest : MonoBehaviour
{
private bool HasAnyEntry;
private bool HasSpecificEntry;
public string EntryName = "PlayerName";
public void Start(){
HasAnyEntry = XenoPrefs.HasEntry();
HasSpecificEntry = XenoPrefs.HasEntry(EntryName);
if(HasAnyEntry){
Debug.Log("There are Entries in XenoPrefs");
}
if(HasSpecificEntry){
Debug.Log(EntryName+" was found in XenoPrefs");
}
}
}
Delete Entries:
You can use XenoPrefs.Delete()
to delete all entries.
You can use XenoPrefs.Delete(string EntryName)
delete a specific entry.
A small Example:
using UnityEngine;
public class EntryTest : MonoBehaviour
{
public string EntryName = "PlayerName";
public void Start(){
XenoPrefs.Delete(EntryName); //Deletes only PlayerName
XenoPrefs.Delete(); //Deletes all Entries
}
}
XenoSaver:
The GameObject ★XenoSaver will be automaticly created by XenoPrefs when its needed.
But you can also drag 'n drop the ★XenoSaver Prefab in to your scene.
★XenoSaver is needed to write your Saves to the Savefile automaticly when the Game ends.
However you can disable this functianlity in the inspector and call XenoPrefs.Save()
manually.
XenoManager:
The XenoManager is an Editor window allowing you to manage your Entries.
It's a great tool for debugging since the Savefile is Crypted.
The XenoManager Editor window can be found at Erarnitox->XenoManager
in the Unity menu bar.
==If you build for Android you cant change the Savefile here.
But you can set them in your code (take a look at section: Advanced)==
Advanced:
Set Savefile Options:
You can set your Savefile Options not only in the XenoManager Editor Window but in a custom Monobehavior as well.
You should only set those options once in the Start()
Methode in the fist scene of the Project.
I recommend using this way of setting the Savefile Options only on Android builds.
==Changing these options will delete the old Savefile!==
==Be aware where you have write permissions!==
Here is an example:
using UnityEngine;
public class SavefileTest : MonoBehaviour
{
public void Start(){
//XenoPrefs.SetSaveName(string Filename) sets a new Filename for the Savefile:
XenoPrefs.SetSaveName("filename.extention");
//XenoPrefs.SetSavePath(string Path) sets a new Path to save the Savefile in:
XenoPrefs.SetSavePath("~\\Saves"");
//XenoPrefs.SetPassword(string Password) sets a new Encryption Password for the Savefile:
XenoPrefs.SetPassword("P8h4d78");
}
}
Load List of Entries:
Example:
using UnityEngine;
public class EntryTest : MonoBehaviour
{
private List<int> int_Values = new List<int>(); //Create a new int list
private List<float> float_Values = new List<float>(); //Create new float list
private List<string> string_Values = new List<string>(); //Create new string list
public void Start(){
//XenoPrefs.GetInts() returns a List containing all int Values Saved:
int_Values() = XenoPrefs.GetInts();
//XenoPrefs.GetFloats() returns a List containing all float Values Saved:
float_Values() = XenoPrefs.GetFloats();
//XenoPrefs.GetStrings() returns a List containing all string Values Saved:
string_Values() = XenoPrefs.GetStrings();
}
}
Load List of Entry Names:
Example:
using UnityEngine;
public class EntryTest : MonoBehaviour
{
//Create new string Lists:
private List<string> int_Names = new List<string>();
private List<string> float_Names = new List<string>();
private List<string> string_Names = new List<string>();
public void Start(){
//XenoPrefs.GetIntNames() returns a List containing all int Entry Names:
int_Names() = XenoPrefs.GetIntNames();
//XenoPrefs.GetFloatNames() returns a List containing all float Entry Names:
float_Names() = XenoPrefs.GetFloatNames();
//XenoPrefs.GetStringNames() returns a List containing all string Entry Names:
string_Names() = XenoPrefs.GetStringNames();
}
}
Things you should know:
Entries with the same name:
It is possible to save values of a different data type under the same name.
But doing that could cause problems when deleteing an entry.
Delete(string EntryName) deletes the first entry matching the given name.
Data types are ignored.
Thank you for your interest.
If you are still interested you can download the package from here.
Also feel free to leave suggestins or questions below.
Hi! I am a robot. I just upvoted you! I found similar content that readers might be interested in:
https://stackoverflow.com/questions/43309034/python-pandas-return-default-value-when-match-not-found
This has absolutely nothing to do with the article.
bad bot
Congratulations @erarnitox! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
Award for the number of upvotes
Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP