Falco Engine 3.9.0.1 (beta)
PlayerPrefs.cs
Go to the documentation of this file.
1using System;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5namespace FalcoEngine
6{
7 public class PlayerPrefs
8 {
9 [MethodImpl(MethodImplOptions.InternalCall)]
10 private static extern bool TrySetInt(string key, int value);
11
12 [MethodImpl(MethodImplOptions.InternalCall)]
13 private static extern bool TrySetFloat(string key, float value);
14
15 [MethodImpl(MethodImplOptions.InternalCall)]
16 private static extern bool TrySetString(string key, string value);
17
23 public static void SetInt(string key, int value)
24 {
25 if (!TrySetInt(key, value))
26 {
27 throw new Exception("Could not store preference value");
28 }
29 }
30
36 [MethodImpl(MethodImplOptions.InternalCall)]
37 public static extern int GetInt(string key, int defaultValue);
38
44 public static int GetInt(string key)
45 {
46 return GetInt(key, 0);
47 }
48
54 public static void SetFloat(string key, float value)
55 {
56 if (!TrySetFloat(key, value))
57 {
58 throw new Exception("Could not store preference value");
59 }
60 }
61
67 [MethodImpl(MethodImplOptions.InternalCall)]
68 public static extern float GetFloat(string key, float defaultValue);
69
75 public static float GetFloat(string key)
76 {
77 return GetFloat(key, 0f);
78 }
79
85 public static void SetString(string key, string value)
86 {
87 if (!TrySetString(key, value))
88 {
89 throw new Exception("Could not store preference value");
90 }
91 }
92
98 [MethodImpl(MethodImplOptions.InternalCall)]
99 public static extern string GetString(string key, string defaultValue);
100
106 public static string GetString(string key)
107 {
108 return GetString(key, "");
109 }
110
115 [MethodImpl(MethodImplOptions.InternalCall)]
116 public static extern bool HasKey(string key);
117
122 [MethodImpl(MethodImplOptions.InternalCall)]
123 public static extern void DeleteKey(string key);
124
128 [MethodImpl(MethodImplOptions.InternalCall)]
129 public static extern void DeleteAll();
130
134 [MethodImpl(MethodImplOptions.InternalCall)]
135 public static extern void Save();
136 }
137}
static string GetString(string key)
Definition: PlayerPrefs.cs:106
static void DeleteAll()
static void DeleteKey(string key)
static float GetFloat(string key)
Definition: PlayerPrefs.cs:75
static void SetFloat(string key, float value)
Definition: PlayerPrefs.cs:54
static void SetString(string key, string value)
Definition: PlayerPrefs.cs:85
static int GetInt(string key, int defaultValue)
static string GetString(string key, string defaultValue)
static float GetFloat(string key, float defaultValue)
static void SetInt(string key, int value)
Definition: PlayerPrefs.cs:23
static bool HasKey(string key)
static int GetInt(string key)
Definition: PlayerPrefs.cs:44