Skip to content

Commit 8f047fc

Browse files
authored
Add scene name violation (#21)
User exported scenes cannot have the same names as the ones we have in the Homescreen. Since the Unity scene APIs are heavily reliant on scene names, this would create conflicts. These include Launcher, Video, OculusQuest, Pico and Wave.
2 parents 8e74104 + a439783 commit 8f047fc

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

Assets/MXRUS/Editor/SceneExportValidator.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public List<SceneExportViolation> Validate() {
3131

3232
violations.AddRange(GetAudioListenerViolations());
3333

34+
var sceneNameViolations = GetSceneNameViolation();
35+
if (sceneNameViolations != null)
36+
violations.Add(sceneNameViolations);
37+
3438
return violations;
3539
}
3640

@@ -217,5 +221,25 @@ private List<SceneExportViolation> GetUserAreaViolations() {
217221
}
218222
return null;
219223
}
224+
225+
private SceneExportViolation GetSceneNameViolation() {
226+
List<string> reservedNames = new List<string> {
227+
"Launcher",
228+
"Video",
229+
"OculusQuest",
230+
"Pico",
231+
"Wave"
232+
};
233+
234+
var activeScene = SceneManager.GetActiveScene();
235+
if(reservedNames.Contains(activeScene.name)) {
236+
return new SceneExportViolation(
237+
SceneExportViolation.Types.SceneNameViolation,
238+
true,
239+
$"The scene name not allowed. The following names are prohibited: {string.Join(", ", reservedNames)}"
240+
);
241+
}
242+
return null;
243+
}
220244
}
221245
}

Assets/MXRUS/Editor/SceneExportViolation.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,14 @@ public enum Types {
5252
MultipleUserAreaProvidersFound,
5353

5454
/// <summary>
55-
/// if the scene has an AudioListener
55+
/// If the scene has an AudioListener
5656
/// </summary>
57-
AudioListenerFound
57+
AudioListenerFound,
58+
59+
/// <summary>
60+
/// Whether the scene name is allowed.
61+
/// </summary>
62+
SceneNameViolation
5863
}
5964

6065
/// <summary>
@@ -77,7 +82,7 @@ public enum Types {
7782
/// </summary>
7883
public Object Object { get; private set; }
7984

80-
public SceneExportViolation(Types type, bool preventsExport, string description, Object obj) {
85+
public SceneExportViolation(Types type, bool preventsExport, string description, Object obj = null) {
8186
Type = type;
8287
PreventsExport = preventsExport;
8388
Description = description;

0 commit comments

Comments
 (0)