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

[BUG] Refresh Unity's asset databases when saving script option not working #1530

Open
NgoTuan-Hung opened this issue Oct 11, 2024 · 9 comments
Labels
area-unity Unity support question Further information is requested

Comments

@NgoTuan-Hung
Copy link

NgoTuan-Hung commented Oct 11, 2024

Describe the Issue

  • I've to Alt + Tab back to unity after saving a c# script in VSCode for refreshing.
  • I've checked the option in VSCode Unity Extension setting
  • I've enabled auto refresh option in Unity preferences setting
  • I've set external script editor as VSCode in Unity

Steps To Reproduce

No response

Expected Behavior

Saving script and refreshing without having to re-focus back on Unity. (This worked before, idk why it doesn't work now)

Environment Information

  • Window 11 LTS
  • VSCode LTS (Unity Extension LTS)
  • Unity 2022.3.41f1
@NgoTuan-Hung NgoTuan-Hung added the bug Something isn't working label Oct 11, 2024
@webreidi webreidi added the area-unity Unity support label Oct 14, 2024
@sailro
Copy link
Member

sailro commented Oct 16, 2024

Hello, I just tried with:

  • Unity 2022.3.50f1 with the VS Editor package 2.0.22
  • VS Code 1.94.1 with the Unity extension 1.0.4

Everything is working as expected. No need to switch focus. So perhaps double check your setup, and in particular your firewall. Both Unity and VSCode processes need to be able to use both TCP+UDP connections.

@sailro sailro added question Further information is requested and removed bug Something isn't working labels Oct 16, 2024
@NgoTuan-Hung
Copy link
Author

I have no idea what is wrong, I've checked everything:

  • VS Editor package 2.0.22
  • VSCode Unity extension 1.0.4
  • I even switch to Unity 6.x but it still doesn't work
  • all firewalls are turned off

The only thing that worked is the Unity Auto-Compile extension by Alireza Zibaeyan, but it doesn't work as seamlessly as the Unity extension.

@sailro
Copy link
Member

sailro commented Oct 16, 2024

And just to double-check, did you have a look at VSCode settings, under File/Preferences/Settings/Extensions/Unity :

Image

@NgoTuan-Hung
Copy link
Author

I ticked them all, both in user and workspace setting.

@jbevain
Copy link
Member

jbevain commented Oct 16, 2024

This is curious. One last thing to check would be the value of https://docs.unity3d.com/ScriptReference/Application-runInBackground.html in the context of the Editor.

If it's set to false, it needs to be set to true for Unity to process our network request in the background. Unity project templates usually set that to true. Maybe that's not the case for you.

@NgoTuan-Hung
Copy link
Author

Still not working, I think I will stick with the other extension for now.

@charlietran
Copy link

Observing this issue as well:

  • MacOS 15.1.1
  • Unity 6000.0.29f1
  • Unity Visual Studio Editor package 2.0.22
  • VSCode 1.96.0
  • VSCode Unity package 1.0.5

Any way we can debug whether the package is attempting to refresh the asset DB or not? I do not see any relevant logs in the Output tab of VSCode under the "C# Dev Kit" or "Unity" sections.

@charlietran
Copy link

@jbevain @sailro could you provide any more info about the TCP/UDP connection between the VSCode extension and Unity? Is there any way I could send a test payload to see whether the issue is with Unity or VSCode?

@NgoTuan-Hung
Copy link
Author

NgoTuan-Hung commented Feb 14, 2025

@charlietran I recommend using this extension for now. Worked decently for me and only cost a negligible amount of cpus: https://assetstore.unity.com/packages/tools/utilities/background-recompiler-234979#description. (You can use it alongside with Unity Extension, just turn refresh database option off.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-unity Unity support question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants