Tanoda
CorePreferences.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9using UnityEngine;
10using UnityEditor;
11
12namespace Leap.Unity {
13
14 public static class CorePreferences {
15
16 private const string ALLOW_CLEAR_TRANSFORM_HOTKEY_KEY =
17 "LeapMotion_AllowClearTransformHotkey";
18 private const string ALLOW_GROUP_OBJECTS_HOTKEY_KEY =
19 "LeapMotion_AllowGroupObjectsHotkey";
20 private const string ALLOW_DESELECT_ALL_HOTKEY_KEY =
21 "LeapMotion_AllowDeselectAllHotkey";
22
23 public static bool allowClearTransformHotkey {
24 get {
25 return EditorPrefs.GetBool(ALLOW_CLEAR_TRANSFORM_HOTKEY_KEY, defaultValue: false);
26 }
27 set {
28 EditorPrefs.SetBool(ALLOW_CLEAR_TRANSFORM_HOTKEY_KEY, value);
29 }
30 }
31
32 public static bool allowGroupObjectsHotkey {
33 get {
34 return EditorPrefs.GetBool(ALLOW_GROUP_OBJECTS_HOTKEY_KEY, defaultValue: false);
35 }
36 set {
37 EditorPrefs.SetBool(ALLOW_GROUP_OBJECTS_HOTKEY_KEY, value);
38 }
39 }
40
41 public static bool allowDeselectAllHotkey {
42 get {
43 return EditorPrefs.GetBool(ALLOW_DESELECT_ALL_HOTKEY_KEY, defaultValue: false);
44 }
45 set {
46 EditorPrefs.SetBool(ALLOW_DESELECT_ALL_HOTKEY_KEY, value);
47 }
48 }
49
50 [LeapPreferences("Core", 0)]
51 private static void drawCorePreferences() {
52 drawPreferencesBool(ALLOW_CLEAR_TRANSFORM_HOTKEY_KEY, "Clear Transforms Hotkey", "When you press Ctrl+E, clear out the local position, rotation, and scale of the selected transforms.");
53 drawPreferencesBool(ALLOW_GROUP_OBJECTS_HOTKEY_KEY, "Group Transforms Hotkey", "When you press Ctrl+G, group all selected objects underneath a single new object named Group.");
54 drawPreferencesBool(ALLOW_DESELECT_ALL_HOTKEY_KEY, "Deselect All Hotkey", "When you press Ctrl+Shift+D, deselect all objects.");
55 }
56
57 private static void drawPreferencesBool(string key, string label, string tooltip) {
58 GUIContent content = new GUIContent(label, tooltip);
59
60 bool value = EditorPrefs.GetBool(key, defaultValue: false);
61 var newValue = EditorGUILayout.Toggle(content, value);
62 if (newValue != value) {
63 EditorPrefs.SetBool(key, newValue);
64 }
65 }
66 }
67}