From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/Utilities/PlayerPrefs.h | 65 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Runtime/Utilities/PlayerPrefs.h (limited to 'Runtime/Utilities/PlayerPrefs.h') diff --git a/Runtime/Utilities/PlayerPrefs.h b/Runtime/Utilities/PlayerPrefs.h new file mode 100644 index 0000000..fbb693c --- /dev/null +++ b/Runtime/Utilities/PlayerPrefs.h @@ -0,0 +1,65 @@ +#ifndef PLAYERPREFS_H +#define PLAYERPREFS_H + +#include +#include + +#if UNITY_EDITOR +class EditorPrefs { +public: + + static void UseCleanTestPrefs (); + static bool SetInt (const std::string& name, int value); + static bool SetBool (const std::string& name, bool value); + static bool SetString (const std::string& name, const std::string& value); + static bool SetFloat (const std::string& name, float value); + + static int GetInt (const std::string& name, int def = 0); + static bool GetBool (const std::string& name, bool def = false); + static std::string GetString (const std::string& name, const std::string& def = std::string ()); + static float GetFloat (const std::string& name, float def = 0.0F); + + static bool HasKey (const std::string& name); + static void DeleteKey (const std::string& name); + static void DeleteAll (); + + static void Sync (); +}; +#endif + +class PlayerPrefs { +public: + typedef std::vector RawData; +public: + static bool SetInt (const std::string& name, int value); + static bool SetString (const std::string& name, const std::string& value); + static bool SetFloat (const std::string& name, float value); + + static int GetInt (const std::string& name, int def = 0); + static std::string GetString (const std::string& name, const std::string& def = std::string ()); + static float GetFloat (const std::string& name, float def = 0.0F); + + static bool HasKey (const std::string& name); + static void DeleteKey (const std::string& name); + static void DeleteAll (); + + #if UNITY_WII_API && (UNITY_WIN || UNITY_WII) + static bool GetRawData(RawData& rawData); + static bool SetRawData(const RawData& rawData); + #endif + + static void Sync (); + #if UNITY_METRO + static void Init(); + #elif WEBPLUG + static void Init (const std::string& playerURL); + #endif + #if UNITY_LINUX + static std::string GetPath (); + #endif + + static void StaticInitialize(); + static void StaticDestroy(); +}; + +#endif -- cgit v1.1-26-g67d0