1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
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 }
|