Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attach to Unity Editor configuration from dll project #1445

Closed
van800 opened this issue Dec 10, 2019 · 13 comments
Closed

Attach to Unity Editor configuration from dll project #1445

van800 opened this issue Dec 10, 2019 · 13 comments
Assignees

Comments

@van800
Copy link
Contributor

van800 commented Dec 10, 2019

In Unity Dll project we have run-configuration Attach to Unity Editor.
Previously it worked in one click when one Unity instance was present.
Now it just shows error pop-up.
image

@van800 van800 added this to the Rider 2020.1 milestone Dec 10, 2019
@van800 van800 self-assigned this Dec 10, 2019
@van800
Copy link
Contributor Author

van800 commented Dec 10, 2019

Same behavior for regular Unity project when EditorInstance.json is missing for some reason.

@van800
Copy link
Contributor Author

van800 commented Dec 11, 2019

@citizenmatt the plan is to restore attaching to single instance of opened Unity and show dialog if there is more than one. Do you agree?

@citizenmatt
Copy link
Member

The attach to single instance step was removed because it's essentially attaching to a random instance of Unity, and IMO it's better to show a dialog to confirm it's the right project in this case, and we shouldn't normally hit this scenario because either Unity or the plugin create EditorInstance.json. The main bug here is that showing the dialog has broken, probably because we've pushed checks to a separate thread.

How about this:

  • Get list of editor processes
  • Find the editor that matches the last attached process id, if it exists
  • Else find the editor that matches EditorInstance.json, if it exists
  • Else find the editor that matches the current project name, if it exists
  • Show dialog for confirmation

There are circumstances on Windows (essentially not launched from Hub, with the -projectPath parameter) where we don't know an editor instance's project name, so we'd show the dialog. But the next time they hit debug, we've saved the pid, so it should match and attach without showing the dialog.

@Borluse
Copy link

Borluse commented Dec 12, 2019

Is there any workaround currently? It's totally unusable for me because our whole scripts have been move out of Unity.

@van800
Copy link
Contributor Author

van800 commented Dec 12, 2019

There is still Attach to Unity in the main menu.

@Borluse
Copy link

Borluse commented Dec 12, 2019

image
not working, it can't find unity.

@Borluse
Copy link

Borluse commented Dec 12, 2019

also, if i've attached to unity by rider 2019.2, then 2019.3 works perfectly, but not after restart unity.

@citizenmatt
Copy link
Member

@Borluse From the screenshot above - did you have Unity running at that time? If so, what's the name of the Unity process? We basically get the current list of processes and filter down by process name.

@Borluse
Copy link

Borluse commented Dec 12, 2019

@Borluse From the screenshot above - did you have Unity running at that time? If so, what's the name of the Unity process? We basically get the current list of processes and filter down by process name.

Yes, it is running.
and task manager
image
EditorInstance.json is correct
image

@van800
Copy link
Contributor Author

van800 commented Dec 12, 2019

This issue might be caused by #1454
I can reproduce it.

@Borluse
Copy link

Borluse commented Dec 12, 2019

This issue might be caused by #1454
I can reproduce it.

Exactly, i used to start my project from commandline. Tried starting unity directly, and it seems working.
image

@citizenmatt
Copy link
Member

The problem is that the command line has a backslash followed by a quote, e.g. Unity.exe "C:\Projects\SpaceGame\", and the code to extract the project name is treating the \" as an escape char, so instead of removing the quotes, it removes the \ and leaves the quotes. This breaks path parsing, which causes an exception, which breaks the whole dialog.

Apologies for this, a fix is in progress as part of #1450, in the meantime, the workaround is to avoid the trailing slash in the command line, or even to use forward slashes, which is what Unity Hub does.

@Borluse
Copy link

Borluse commented Dec 12, 2019

The problem is that the command line has a backslash followed by a quote, e.g. Unity.exe "C:\Projects\SpaceGame\", and the code to extract the project name is treating the \" as an escape char, so instead of removing the quotes, it removes the \ and leaves the quotes. This breaks path parsing, which causes an exception, which breaks the whole dialog.

Apologies for this, a fix is in progress as part of #1450, in the meantime, the workaround is to avoid the trailing slash in the command line, or even to use forward slashes, which is what Unity Hub does.

Thanks! Changing commandline's project path from "d:\xx\xx" to "d:/xx/xx" works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants