Anti-Cheat Toolkit
2024.3.3
Multi-purpose anti-cheat solution for Unity Engine
|
Static Public Member Functions | |
static void | Init (bool loadPrefs=false) |
static void | Init (string fileName, bool loadPrefs) |
static void | Init (IObscuredFileSettings settings, bool loadPrefs) |
static void | Init (string fileNameOrPath, IObscuredFileSettings settings, bool loadPrefs) |
static void | UnInit () |
static void | LoadPrefs () |
static void | UnloadPrefs (bool saveBeforeUnloading=true) |
static bool | HasKey (string key) |
static ICollection< string > | GetKeys () |
static void | DeleteKey (string key) |
static void | DeleteAll () |
static bool | Save () |
static void | Set< T > (string key, T value) |
static T | Get< T > (string key, T defaultValue=default) |
Static Public Attributes | |
const string | DefaultFileName = "actkfileprefs" |
Properties | |
static IObscuredFileSettings | CurrentSettings [get] |
static bool | IsInited [get] |
static bool | IsLoaded [get] |
static bool | IsExists [get] |
static bool | IsSaved [get] |
static bool | IsBusy [get] |
static string | FilePath [get] |
static ObscuredFileReadResult | LastFileReadResult [get] |
static ObscuredFileWriteResult | LastFileWriteResult [get] |
Events | |
static Action | NotGenuineDataDetected |
static Action | DataFromAnotherDeviceDetected |
ObscuredPrefs analogue but uses File IO instead of PlayerPrefs as a backend, has more flexibility and can work from a background thread.
Don't forget to call Save() when you wish to save prefs file. You can call it from background thread. It also will save automatically on non-abnormal application quit (relies on Application.wantsToQuit API).
Please call DeviceIdHolder.ForceLockToDeviceInit before accessing this class from background thread if you are using Device Lock feature without custom DeviceID.
|
inlinestatic |
Initializes ObscuredFilePrefs with file name set to DefaultFileName and default ObscuredFileSettings.
loadPrefs | Pass true to automatically call LoadPrefs(). This may block calling thread, consider using asynchronously for large files. |
|
inlinestatic |
Initializes ObscuredFilePrefs with specified file name and default ObscuredFileSettings.
fileName | Custom file name to place at ObscuredFileLocation.PersistentData. |
loadPrefs | Pass true to automatically call LoadPrefs(). This may block calling thread, consider using asynchronously for large files. |
|
inlinestatic |
Initializes ObscuredFilePrefs with file name set to DefaultFileName and custom specific settings.
settings | Specific custom settings. |
loadPrefs | Pass true to automatically call LoadPrefs(). This may block calling thread, consider using asynchronously for large files. |
|
inlinestatic |
Initializes ObscuredFilePrefs with specified file name or file path and custom specific settings.
fileNameOrPath | File path if using ObscuredFileLocation.Custom, otherwise represents file name to use with set ObscuredFileLocation kind. |
settings | Specific custom settings. |
loadPrefs | Pass true to automatically call LoadPrefs(). This may block calling thread, consider using asynchronously for large files. |
|
inlinestatic |
Releases internal prefs cache, unsubscribes events and frees other used resources.
Please call Init() again if you wish to re-use it.
|
inlinestatic |
Loads prefs from existing file if it wasn't loaded before.
This function will read from disk potentially causing a hiccup especially when you have lots of data in your prefs, therefore it is not recommended to call it synchronously during actual game play. Instead, call it from separate thread asynchronously or at loading screens and other stall moments of your app.
|
inlinestatic |
Unloads cached prefs from memory. Optionally saves current prefs to the file before unloading.
WARNING: Unsaved data will be lost!
|
inlinestatic |
Returns true if key
exists in the ObscuredFilePrefs.
Calls LoadPrefs() internally.
|
inlinestatic |
Returns all existing prefs keys in current ObscuredFilePrefs.
Calls LoadPrefs() internally.
|
inlinestatic |
Removes key
and its corresponding value from the ObscuredFilePrefs.
Calls LoadPrefs() internally.
|
inlinestatic |
Use with caution! Removes all keys and values from the prefs.
|
inlinestatic |
Writes all modified prefs to underlying ObscuredFile on disk.
By default, prefs are saved to disk on Application Quit (relies on Application.wantsToQuit API).
In case when the app crashes or otherwise prematurely exits, you might want to write the prefs at sensible 'checkpoints' in your app.
This function will write to disk potentially causing a hiccup especially when you have lots of data in your prefs, therefore it is not recommended to call it synchronously during actual game play. Instead, call it from separate thread asynchronously or at loading screens and other stall moments of your app.
|
inlinestatic |
Sets the value
of the preference identified by key
.
WARNING: Not all types are supported, see StorageDataType for list of supported types.
|
inlinestatic |
Returns the value corresponding to key
in the preference file if it exists. If it doesn't exist, it will return defaultValue
.
WARNING: Not all types are supported, see StorageDataType for list of supported types.
|
static |
Filename used by default, if other name or path was not specified in constructor.
|
staticget |
|
staticget |
Allows checking if Init() was called previously.
|
staticget |
Allows checking if prefs cache was loaded \ initialized. It can be true while IsExists is false if new prefs was not saved yet.
|
staticget |
Returns true if prefs file physically exists on disk. File may not exist until Save() is called.
|
staticget |
Returns true if prefs file has unsaved changes.
|
staticget |
Returns true if prefs file is busy with long-running process such as loading or saving.
|
staticget |
Returns path to the prefs file. It's always not empty and valid even if prefs was not saved to the physical file yet.
|
staticget |
Contains reference to the last underlying ObscuredFile read operation result.
Filled on prefs file read.
May be invalid if no read operations were executed. Check ObscuredFileReadResult.IsValid property to figure this out.
|
staticget |
Contains reference to the last underlying ObscuredFile write operation result.
Filled on prefs file saving.
May be invalid if no write operations were executed yet. Check ObscuredFileWriteResult.IsValid property to figure this out.
|
static |
Fires when saved data tampering detected. Will not fire when data is damaged and not readable.
|
static |
Fires when saved data from some other device detected.
May be helpful to ban potential cheaters, trying to use someone's purchased in-app goods for example.
NOTE: Will fire if same device ID has changed (pretty rare case though). Read more at DeviceLockLevel.