18 #region Settings & Init
20 private const string WINDOW_TITLE =
"Leap Motion Unity Modules";
21 private static readonly Vector2 WINDOW_MIN_SIZE =
new Vector2(600f, 600f);
29 private const string LEAP_UNITY_WINDOW_LAUNCHED_PREF =
"Leap Unity Window Launched";
35 EditorApplication.delayCall += () => {
36 if (!EditorPrefs.GetBool(LEAP_UNITY_WINDOW_LAUNCHED_PREF)) {
37 EditorPrefs.SetBool(LEAP_UNITY_WINDOW_LAUNCHED_PREF,
true);
43 [MenuItem(
"Window/Leap Motion")]
44 public static void Init() {
46 utility:
true, title: WINDOW_TITLE, focus:
true);
47 window.name =
"Leap Motion Unity Modules Window";
48 window.minSize = WINDOW_MIN_SIZE;
49 _currentWindow = window;
56 private string leapLogoResourceName {
58 if (EditorGUIUtility.isProSkin)
return "LM_Logo_White";
59 else return "LM_Logo_Black";
63 private Texture2D _backingLeapTex =
null;
64 private Texture2D leapTex {
66 if (_backingLeapTex ==
null) {
67 _backingLeapTex = EditorResources.Load<Texture2D>(leapLogoResourceName);
69 return _backingLeapTex;
73 private static GUISkin s_backingWindowSkin;
76 if (s_backingWindowSkin ==
null) {
77 s_backingWindowSkin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Scene);
79 return s_backingWindowSkin;
89 return _currentWindow !=
null;
93 private int _tabIndex = 0;
94 private static string[] _tabs =
new string[] {
95 "Project Checks",
"Rig Upgrader",
"Preferences"
97 public static void ShowTab(
int tabIndex) {
98 if (_currentWindow !=
null) {
99 _currentWindow._tabIndex = tabIndex;
104 private Vector2 _scrollPosition = Vector2.zero;
110 private void OnGUI() {
111 var origSkin = GUI.skin;
122 private void drawGUI() {
124 GUILayout.BeginVertical();
128 logoStyle.fixedHeight = 150;
129 logoStyle.stretchWidth =
true;
130 logoStyle.alignment = TextAnchor.MiddleCenter;
131 logoStyle.margin =
new RectOffset(0, 0, top: 20, bottom: 20);
132 GUILayout.Box(
new GUIContent(leapTex), logoStyle, GUILayout.ExpandWidth(
true),
133 GUILayout.MaxHeight(150f));
136 _tabIndex = GUILayout.Toolbar(_tabIndex, _tabs);
137 _scrollPosition = GUILayout.BeginScrollView(_scrollPosition,
138 GUILayout.ExpandWidth(
true), GUILayout.ExpandHeight(
true));
141 LeapProjectChecks.DrawProjectChecksGUI();
144 LeapRigUpgrader.DrawUpgraderGUI();
147 float prevLabelWidth = EditorGUIUtility.labelWidth;
148 EditorGUIUtility.labelWidth = 200;
150 EditorGUIUtility.labelWidth = prevLabelWidth;
156 GUILayout.EndScrollView();
158 GUILayout.EndVertical();
This attribute is used to add items to the Leap Motion preferences window. This allows each module to...
static GUISkin windowSkin
static void ShowTab(int tabIndex)