diff options
Diffstat (limited to 'Runtime/Export/PlayerPrefsBindings.txt')
-rw-r--r-- | Runtime/Export/PlayerPrefsBindings.txt | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/Runtime/Export/PlayerPrefsBindings.txt b/Runtime/Export/PlayerPrefsBindings.txt new file mode 100644 index 0000000..331886e --- /dev/null +++ b/Runtime/Export/PlayerPrefsBindings.txt @@ -0,0 +1,115 @@ +C++RAW + + +#include "UnityPrefix.h" +#include "Configuration/UnityConfigure.h" +#include "Runtime/Mono/MonoManager.h" +#include "Runtime/Graphics/Transform.h" +#include "Runtime/Utilities/PathNameUtility.h" +#include "Runtime/Profiler/ProfilerHistory.h" +#include "Runtime/Allocator/MemoryManager.h" +#include "Runtime/Animation/Animation.h" +#include "Runtime/Utilities/PlayerPrefs.h" +#include "Runtime/Misc/BuildSettings.h" +#include "Runtime/Scripting/Scripting.h" +#include "Runtime/Scripting/ScriptingUtility.h" +#include "Runtime/Scripting/ScriptingExportUtility.h" +#include "Runtime/Scripting/GetComponent.h" +#include "Runtime/Scripting/Backend/ScriptingBackendApi.h" +#include "Runtime/Scripting/Backend/ScriptingTypeRegistry.h" + +using namespace Unity; + +using namespace std; + +CSRAW +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Collections; +using System.Collections.Generic; +using UnityEngineInternal; + +namespace UnityEngine +{ + + +// This exception is thrown by the [[PlayerPrefs]] class in the Web player if the preference file would exceed the allotted storage space when setting a value. +CLASS PlayerPrefsException : Exception + + //*undocumented* + CSRAW public PlayerPrefsException(string error) : base(error) {} +END + +// Stores and accesses player preferences between game sessions. +CLASS PlayerPrefs + CUSTOM private static bool TrySetInt (string key, int value) { return (int)PlayerPrefs::SetInt (key, value); } + CUSTOM private static bool TrySetFloat (string key, float value) { return (int)PlayerPrefs::SetFloat (key, value); } + CUSTOM private static bool TrySetSetString (string key, string value) { return (int)PlayerPrefs::SetString (key, value); } + + // Sets the value of the preference identified by /key/. + CSRAW public static void SetInt (string key, int value) { if( ! TrySetInt(key, value) ) throw new PlayerPrefsException("Could not store preference value"); } + + + // Returns the value corresponding to /key/ in the preference file if it exists. + CUSTOM static int GetInt (string key, int defaultValue = 0) { return PlayerPrefs::GetInt (key, defaultValue); } + + // Sets the value of the preference identified by /key/. + CSRAW public static void SetFloat (string key, float value) { if( ! TrySetFloat(key, value) ) throw new PlayerPrefsException("Could not store preference value"); } + + // Returns the value corresponding to /key/ in the preference file if it exists. + CUSTOM static float GetFloat (string key, float defaultValue = 0.0F) { return PlayerPrefs::GetFloat (key, defaultValue); } + + // Sets the value of the preference identified by /key/. + CSRAW public static void SetString (string key, string value) { if( ! TrySetSetString(key, value) ) throw new PlayerPrefsException("Could not store preference value"); } + + + // Returns the value corresponding to /key/ in the preference file if it exists. + CUSTOM static string GetString (string key, string defaultValue = "") { return scripting_string_new (PlayerPrefs::GetString (key, defaultValue)); } + + // Returns true if /key/ exists in the preferences. + CUSTOM static bool HasKey(string key) { return (int)PlayerPrefs::HasKey(key); } + + // Removes /key/ and its corresponding value from the preferences. + CUSTOM static void DeleteKey(string key) { PlayerPrefs::DeleteKey(key); } + + // Removes all keys and values from the preferences. Use with caution. + CUSTOM static void DeleteAll() { PlayerPrefs::DeleteAll(); } + + // Writes all modified preferences to disk. + CUSTOM static void Save() { PlayerPrefs::Sync(); } + + + // Transfers PlayerPrefs content to and from an array of bytes. Can be useful to implement save/load game functionality. + CONDITIONAL UNITY_WII_API + CUSTOM_PROP static byte[] rawData + { + PlayerPrefs::RawData data; + #if (UNITY_WIN || UNITY_WII) + if (PlayerPrefs::GetRawData(data)) + { + return CreateScriptingArray(&data[0], data.size(), GetMonoManager().GetCommonClasses().byte); + } + else + { + return CreateEmptyStructArray(GetMonoManager().GetCommonClasses().byte); + } + #else + return CreateEmptyStructArray(GetMonoManager().GetCommonClasses().byte); + #endif + } + { + size_t size = GetScriptingArraySize(value); + UInt8 const* begin = Scripting::GetScriptingArrayStart<UInt8>(value); + UInt8 const* end = begin + size; + PlayerPrefs::RawData data (begin, end); + #if (UNITY_WIN || UNITY_WII) + if (!PlayerPrefs::SetRawData(data)) + printf_console ("Failed to load PlayerPrefs from rawData (size:%d)\n", size); + #endif + } + +END + +CSRAW } + |