-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[REG-2105] Allow absolute paths to be used in segment and sequence loading #333
Conversation
@vontell none of that sounds right to me at first read.. i'll go recreate this and clarify |
@vontell I ran this locally on Windows, and everything seems to be working correctly in-editor and in a build. |
See new Update below after testing on Mac. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works on Windows because the path is starting with C:\ not \ or /
Furthermore, looking into how this prompt was interacting with command line sequence runner options, I think this will be safe there as well and should support full or relative paths.
This check existed before I started auto normalizing everything to a resourcePath and then running it through the loading evaluator to make sure we always loaded the override copy, not accidentally something else.
Just to confirm, here is a loom recording and attached logs of a complete reproduction from scratch on RGUnityBots main: https://www.loom.com/share/e66397c926ff4f39acb20e8ac86195a7?sid=56362bb9-05ca-4fb7-8fb1-044fffe58cb1 The @RG-nAmKcAz great point about the recent command line option... will this actually work with that? Because we do manipulate the path to ensure it starts with are particular path... what if my sequence is just located in a random folder? Or does that take another route? I'll take a look myself Update: I do get an error when doing this, will be able to inspect more why that is. Command (for mac): Result
|
@vontell If you want to move the relative paths only check to the option loader that seems most appropriate... but that option is NOT intended to work with arbitrary paths. Sequences/Segments MUST be loaded from the persistent data path or inside the build, thus the normalization to resource paths. IF you want to re-write that concept you can, but this ticket seems to be moving from fix a bug on mac to add new functionality to the command line option |
I see! Just want to confirm this before I merge then since the last time I thought about this was last week:
If that is correct, please provide a thumbs up and I will merge! |
@vontell I would add a check to the option loader asserting that it is a relative path for now. Similar to the existing code, but maybe with an extra bit to save us from c: , e:, etc Doesn't start with '/' or '' and doesn't have a second char of ':' |
RGHeadlessSequenceRunner around line 110 ish , just before we return the path |
@RG-nAmKcAz will do 👍 |
Apologies for the delay on this. @RG-nAmKcAz please see my latest commit for that change - confirmed that the sequence path works properly for relative paths and does print the error message in the logs when it is absolute (the Path utility I use here should properly handle both Windows disks and unix systems) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good. Just need a unique RC for that case
if (Path.IsPathRooted(path)) | ||
{ | ||
RGDebug.LogError($"{SequencePathArgument} command line argument requires a relative path"); | ||
Application.Quit(Rc_SequencePathMissing); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a unique RC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, added
There was a bug where sequences and segments could not be loaded from the application data path in builds. I am not super familiar with all of the logic here so wanted to take a minute to explain my observations and decisions here:
Error reading Bot Sequence /Users/aaronvontell/Library/Application Support/DefaultCompany/normal/RegressionGames/Resources/BotSequences/Latest_Recording.json: System.Exception: Invalid path. Path must be relative, not absolute in order to support editor vs production runtimes interchangeably.
Assets/RegressionGames/Resources/BotSequences/asdasd.json
/Users/aaronvontell/Library/Application Support/com.DefaultCompany.This--should-break-/RegressionGames/Resources/BotSequences/Latest_Recording.json
ToResourcePath
function, and then reconstructing it... and the LoadJsonResource function knows how to handle both scenarios.An alternative to my change is to only call ToResourcePath inside of the
UNITY_EDITOR
scenarios and then use the path directly inside of the else block, so that the path doesn't need to be reconstructed. However, I wanted to check with @RG-nAmKcAz and @addisonbgross that this is still fine considering the "override" behavior, or if there is additional logic I need to consider.At least on mac, I confirmed that this allows us to both create and see sequences that are in the application data path, and everything behaves as expected in builds and in editor. Note, however, that the sequences and segments inside the application data path do not show in the editor (which I believe is expected, but wanted to confirm).