AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
EditorPrefsUtility.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
4 using UnityEditor;
5 using UnityEngine;
6 
7 namespace HoloToolkit.Unity
8 {
9  public static class EditorPrefsUtility
10  {
11  public static void SetEditorPref(string key, string value)
12  {
13  EditorPrefs.SetString(Application.productName + key, value);
14  }
15 
16  public static void SetEditorPref(string key, bool value)
17  {
18  EditorPrefs.SetBool(Application.productName + key, value);
19  }
20 
21  public static void SetEditorPref(string key, float value)
22  {
23  EditorPrefs.SetFloat(Application.productName + key, value);
24  }
25 
26  public static void SetEditorPref(string key, int value)
27  {
28  EditorPrefs.SetInt(Application.productName + key, value);
29  }
30 
31  public static string GetEditorPref(string key, string defaultValue)
32  {
33  if (EditorPrefs.HasKey(Application.productName + key))
34  {
35  return EditorPrefs.GetString(Application.productName + key);
36  }
37 
38  EditorPrefs.SetString(Application.productName + key, defaultValue);
39  return defaultValue;
40  }
41 
42  public static bool GetEditorPref(string key, bool defaultValue)
43  {
44  if (EditorPrefs.HasKey(Application.productName + key))
45  {
46  return EditorPrefs.GetBool(Application.productName + key);
47  }
48 
49  EditorPrefs.SetBool(Application.productName + key, defaultValue);
50  return defaultValue;
51  }
52 
53  public static float GetEditorPref(string key, float defaultValue)
54  {
55  if (EditorPrefs.HasKey(Application.productName + key))
56  {
57  return EditorPrefs.GetFloat(Application.productName + key);
58  }
59 
60  EditorPrefs.SetFloat(Application.productName + key, defaultValue);
61  return defaultValue;
62  }
63 
64  public static int GetEditorPref(string key, int defaultValue)
65  {
66  if (EditorPrefs.HasKey(Application.productName + key))
67  {
68  return EditorPrefs.GetInt(Application.productName + key);
69  }
70 
71  EditorPrefs.SetInt(Application.productName + key, defaultValue);
72  return defaultValue;
73  }
74  }
75 }
static void SetEditorPref(string key, bool value)
static int GetEditorPref(string key, int defaultValue)
static float GetEditorPref(string key, float defaultValue)
static void SetEditorPref(string key, string value)
static void SetEditorPref(string key, float value)
static bool GetEditorPref(string key, bool defaultValue)
static string GetEditorPref(string key, string defaultValue)
static void SetEditorPref(string key, int value)