Skip to content

Commit

Permalink
Fix checks when spawns is null
Browse files Browse the repository at this point in the history
  • Loading branch information
oneVR committed Jan 19, 2021
1 parent af11d01 commit 63d71f5
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions Scripts/Editor/WorldDebugger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1104,11 +1104,11 @@ public static Action FixSpawns(VRC_SceneDescriptor descriptor)
return () =>
{
Undo.RegisterCompleteObjectUndo(descriptor, "Spawn Points Fixed");
descriptor.spawns = descriptor.spawns.Where(c => c != null).ToArray();
if (descriptor.spawns.Length == 0)
if (descriptor.spawns is null || descriptor.spawns.Length == 0)
{
descriptor.spawns = new[] {descriptor.gameObject.transform};
}
descriptor.spawns = descriptor.spawns.Where(c => c != null).ToArray();

PrefabUtility.RecordPrefabInstancePropertyModifications(descriptor);
};
Expand Down Expand Up @@ -1673,17 +1673,13 @@ private void CheckScene()
#endif

// Get spawn points for any possible problems
var spawns = sceneDescriptor.spawns.Where(s => s != null).ToArray();
if (sceneDescriptor.spawns != null && sceneDescriptor.spawns.Length > 0)
{
var spawns = sceneDescriptor.spawns.Where(s => s != null).ToArray();

var spawnsLength = sceneDescriptor.spawns.Length;
var emptySpawns = spawnsLength != spawns.Length;
var spawnsLength = sceneDescriptor.spawns.Length;
var emptySpawns = spawnsLength != spawns.Length;

if (spawns.Length == 0)
{
general.AddMessageGroup(new MessageGroup(NO_SPAWN_POINT_SET, MessageType.Error).AddSingleMessage(new SingleMessage(sceneDescriptor.gameObject).SetAutoFix(FixSpawns(sceneDescriptor))));
}
else
{
if (emptySpawns)
{
general.AddMessageGroup(new MessageGroup(NULL_SPAWN_POINT, MessageType.Error).AddSingleMessage(new SingleMessage(sceneDescriptor.gameObject).SetAutoFix(FixSpawns(sceneDescriptor))));
Expand Down Expand Up @@ -1720,6 +1716,10 @@ private void CheckScene()
}
}
}
else
{
general.AddMessageGroup(new MessageGroup(NO_SPAWN_POINT_SET, MessageType.Error).AddSingleMessage(new SingleMessage(sceneDescriptor.gameObject).SetAutoFix(FixSpawns(sceneDescriptor))));
}

#if VRC_SDK_VRCSDK2
// Check if the world has playermods defined
Expand Down

0 comments on commit 63d71f5

Please sign in to comment.