Skip to content

Commit a91fa96

Browse files
authored
Merge pull request #9974 from keveleigh/mrtk-version
Add editor window and menu item for displaying the current MRTK version
2 parents d2329b6 + b94fd86 commit a91fa96

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
using Microsoft.MixedReality.Toolkit.Utilities.Editor;
5+
using System;
6+
using UnityEditor;
7+
using UnityEngine;
8+
9+
namespace Microsoft.MixedReality.Toolkit.Editor
10+
{
11+
internal class MRTKVersionPopup : EditorWindow
12+
{
13+
private const string DefaultVersion = "0.0.0.0";
14+
private const string NotFoundMessage = "The version could not be read. This is most often due to (and expected when) using MRTK directly from the repo. If you're using an official distribution and seeing this message, please file a GitHub issue!";
15+
private static readonly Version MRTKVersion = typeof(MixedRealityToolkit).Assembly.GetName().Version;
16+
private static readonly bool FoundVersion = MRTKVersion.ToString() != DefaultVersion;
17+
private static readonly Vector2 WindowSize = new Vector2(300, 140);
18+
private static readonly Vector2 NotFoundWindowSize = new Vector2(300, 175);
19+
private static readonly GUIContent Title = new GUIContent("Mixed Reality Toolkit");
20+
private static MRTKVersionPopup window;
21+
22+
[MenuItem("Mixed Reality/Toolkit/Show version...", priority = int.MaxValue)]
23+
private static void Init()
24+
{
25+
if (window != null)
26+
{
27+
window.ShowUtility();
28+
return;
29+
}
30+
31+
window = CreateInstance<MRTKVersionPopup>();
32+
window.titleContent = Title;
33+
window.maxSize = FoundVersion ? WindowSize : NotFoundWindowSize;
34+
window.minSize = FoundVersion ? WindowSize : NotFoundWindowSize;
35+
window.ShowUtility();
36+
}
37+
38+
private void OnGUI()
39+
{
40+
using (new EditorGUILayout.VerticalScope())
41+
{
42+
MixedRealityInspectorUtility.RenderMixedRealityToolkitLogo();
43+
44+
using (new EditorGUILayout.HorizontalScope())
45+
{
46+
GUILayout.FlexibleSpace();
47+
EditorGUILayout.LabelField(FoundVersion ? $"Version {MRTKVersion}" : NotFoundMessage, EditorStyles.wordWrappedLabel);
48+
GUILayout.FlexibleSpace();
49+
}
50+
}
51+
}
52+
}
53+
}

Assets/MRTK/Core/Inspectors/Setup/MRTKVersionPopup.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)