forked from microsoft/MixedRealityToolkit-Unity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeadsetAdjustmentEditor.cs
More file actions
67 lines (59 loc) · 2.22 KB
/
HeadsetAdjustmentEditor.cs
File metadata and controls
67 lines (59 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using System;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
namespace HoloToolkit.Unity
{
[CustomEditor(typeof(HeadsetAdjustment))]
public class HeadsetAdjustmentEditor : Editor
{
private static SceneAsset sceneAsset;
private static Object sceneObj;
private static HeadsetAdjustment myTarget;
private void OnEnable()
{
myTarget = (HeadsetAdjustment)target;
sceneAsset = GetSceneObject(myTarget.NextSceneName);
}
public override void OnInspectorGUI()
{
sceneObj = EditorGUILayout.ObjectField(
new GUIContent("Next Scene", "The name of the scene to load when the user is ready. If left empty, " +
"the next scene is loaded as specified in the 'Scenes in Build')"),
sceneAsset,
typeof(SceneAsset),
true);
if (GUI.changed)
{
if (sceneObj == null)
{
sceneAsset = null;
myTarget.NextSceneName = string.Empty;
}
else
{
sceneAsset = GetSceneObject(sceneObj.name);
myTarget.NextSceneName = sceneObj.name;
}
}
}
private static SceneAsset GetSceneObject(string sceneObjectName)
{
if (string.IsNullOrEmpty(sceneObjectName))
{
return null;
}
foreach (EditorBuildSettingsScene editorScene in EditorBuildSettings.scenes)
{
if (editorScene.path.IndexOf(sceneObjectName, StringComparison.Ordinal) != -1)
{
return AssetDatabase.LoadAssetAtPath(editorScene.path, typeof(SceneAsset)) as SceneAsset;
}
}
Debug.LogWarning("Scene [" + sceneObjectName + "] cannot be used. To use this scene add it to the build settings for the project.");
return null;
}
}
}