diff --git a/src/gg.regression.unity.bots/Runtime/Scripts/RGHeadlessSequenceRunner.cs b/src/gg.regression.unity.bots/Runtime/Scripts/RGHeadlessSequenceRunner.cs index efef3919..1b1e7301 100644 --- a/src/gg.regression.unity.bots/Runtime/Scripts/RGHeadlessSequenceRunner.cs +++ b/src/gg.regression.unity.bots/Runtime/Scripts/RGHeadlessSequenceRunner.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.IO; using System.Linq; using System.Reflection; using RegressionGames.StateRecorder.BotSegments; @@ -23,6 +24,7 @@ public static class RGHeadlessSequenceRunner internal static readonly int Rc_SequenceTimeoutNeedsPath = 5; internal static readonly int Rc_SequenceTimeoutMissing = 6; internal static readonly int Rc_SequenceTimeoutNotInt = 7; + internal static readonly int Rc_SequencePathNotRelative = 8; internal static readonly string SequencePathArgument = "-rgsequencepath"; internal static readonly string SequenceTimeoutArgument = "-rgsequencetimeout"; @@ -124,7 +126,19 @@ internal static string ParsePathArgument() { if (i + 1 < argsLength) { - return args[i + 1]; + + var path = args[i + 1]; + + // Sequences that are run via -rgsequencepath must be relative, as we only allows sequences + // included in the Resource or persistent path directories. + if (Path.IsPathRooted(path)) + { + RGDebug.LogError($"{SequencePathArgument} command line argument requires a relative path"); + Application.Quit(Rc_SequencePathNotRelative); + return null; + } + + return path; } // else RGDebug.LogError($"{SequencePathArgument} command line argument requires a path value to be passed after it"); diff --git a/src/gg.regression.unity.bots/Runtime/Scripts/StateRecorder/BotSegments/Models/BotSequence.cs b/src/gg.regression.unity.bots/Runtime/Scripts/StateRecorder/BotSegments/Models/BotSequence.cs index 1d3db1be..9a78cea1 100644 --- a/src/gg.regression.unity.bots/Runtime/Scripts/StateRecorder/BotSegments/Models/BotSequence.cs +++ b/src/gg.regression.unity.bots/Runtime/Scripts/StateRecorder/BotSegments/Models/BotSequence.cs @@ -46,11 +46,6 @@ public static (string, string, BotSequence) LoadSequenceJsonFromPath(string path return (null, null, null); } - if (path.StartsWith('/') || path.StartsWith('\\')) - { - throw new Exception("Invalid path. Path must be relative, not absolute in order to support editor vs production runtimes interchangeably."); - } - path = path.Replace('\\', '/'); (string, string, string) sequenceJson; @@ -144,10 +139,6 @@ private static object ParseSegmentOrListJson(string resourcePath, string fileDat */ public static (string, string, object) LoadBotSegmentOrBotSegmentListFromPath(string path) { - if (path.StartsWith('/') || path.StartsWith('\\')) - { - throw new Exception("Invalid path. Path must be relative, not absolute, in order to support editor vs production runtimes interchangeably."); - } path = path.Replace('\\', '/');